xxxxxxxxxx
a = "Hello, World!"
print(a.upper())
#output: HELLO, WORLD!
xxxxxxxxxx
myString = "Hello"
myString.upper() #returns "HELLO"
myString.lower() #returns "hello"
Here is how to make a string uppercase and lowercase!
xxxxxxxxxx
original_string = "Hi there"
string_uppercase = original_string.upper()
print(string_uppercase)
string_lowercase = string_uppercase.lower()
print(string_lowercase)
string.upper() makes the string uppercase, but we can only save this uppercase value in a variable. That is why we have to print it in order to display it. The same goes with string.lower(). This makes the entire string into lowercase characters. But again, we must print it in order to display it.
Note that these two functions only work with strings and not with float or integer values, in other words numbers! Good luck coding!
Answer By: Codexel ;)
xxxxxxxxxx
my_string = "this is my string"
print(my_string.upper())
# output: "THIS IS MY STRING"
xxxxxxxxxx
# count uppercase,lowercase,digits and special characters.
a=input('enter the string:')
u=l=d=s=0
for i in a :
if i.isupper():
u+=1
elif i.islower():
l+=1
elif i.isdigit():
d+=1
else:
s+=1
print('if the string is upper',u)
print('if the string is lower',l)
print('if the string is digit',d)
print('if the string is special',s)
#output:
'''
enter the string: 'Hii Buddy! How Have You BEEN , Welcome To PYTHON....
if the string is upper 17
if the string is lower 20
if the string is digit 0
if the string is special 17
'''
xxxxxxxxxx
# String to Uppercase by Matthew Johnson
myStr = "Dna"
print(myStr.upper())
#OUTPUT: "DNA"
xxxxxxxxxx
s=input()
new_str=""
for i in range (len(s)):
if i.isupper():
new_str+=i.lower()
elif i.islower():
new_str+=i.upper()
else:
new_str+=i
print(new_str)
xxxxxxxxxx
S1 = 'Python'
#creates a new string with the contents of S uppercased.
S2 = S1.upper()
print(S2)