Lower () and strip () methods

1
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())

Result:

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 does not it work?

    
asked by anonymous 20.12.2016 / 15:03

1 answer

1

Well, for the whole sentence in capital letters would be:

frase.upper()

For the phrase without spaces:

frase.replace(' ', '')

Explanation:

As for the letters that you wanted in capital letters, you were using the opposite method, you were using the method that changes them to lowercase.

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

    
20.12.2016 / 15:39