Thursday 17 December 2020

Python: Convert string to lower and upper case

lower() method convert a string to lower case, whereas upper() method convert a string to upper case.

 

string_case.py

message = "Hello World"
lowercase_message = message.lower()
uppercase_message = message.upper()

print(message)
print(lowercase_message)
print(uppercase_message)

  Output

 

$python3 string_case.py 
Hello World
hello world
HELLO WORLD

 

 

 

Previous                                                    Next                                                    Home

No comments:

Post a Comment