105k views
4 votes
Which code formats the string "Green" to "GREEN"?

a. .isupper()
b. .capitalize()
c. .istitle()
d. .upper()

User NeaGaze
by
7.7k points

1 Answer

1 vote

Final answer:

To format "Green" to "GREEN", use the method .upper(), which converts all characters to uppercase. Other options like .isupper(), .capitalize(), and .istitle() serve different purposes such as checking case or capitalizing the first character only.

Step-by-step explanation:

To format the string "Green" to "GREEN", the correct method to use is d. .upper(). This method will convert all the lowercase letters in the string to uppercase. Option a, .isupper(), checks if all the letters in the string are uppercase. Option b, .capitalize(), capitalizes only the first character of the string. Option c, .istitle(), checks if the string is titled (each word starts with an uppercase letter followed by lowercase letters).

User Ngoc Tran
by
8.1k points