Lower() and strip() methods

Asked

Viewed 863 times

0

print ("Escreva uma frase toda em maiúscula e sem espaços em branco")

frase = input("Escreva uma frase: ")
print (frase.lower())
print (frase.strip())

Upshot:

Escreva uma frase toda em maiúscula e sem espaços em branco
Escreva uma frase: oi tudo bem?
oi tudo bem?
oi tudo bem?

Why doesn’t it work?

  • 2

    What is not working?

  • print (phrase.Lower()) print (phrase.strip()) ?

1 answer

1


All right, for the whole sentence in uppercase it would be:

frase.upper()

For the sentence without spaces:

frase.replace(' ', '')

Explanation:

As for the letters you wanted to capitalize you were using the opposite method, you were using the method that Uta for minusculas.

And as for removing the spaces, the method strip() only removes them at the beginning and end of the string.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.