Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How do I print only the letters of a list in uppercase?

New to python and working on lists. The items in my lists consists of letters and numbers, and I’m wondering how to print the letters in uppercase. This is what I have.

dirtbike = ['yz450', 'kx450', 'rmz450', 'ktm450', 'fc450']
message = f"I would love to own a {dirtbike[0]}! As well as a {dirtbike[1]}!"
print(message)

I would like the print out to be ‘YZ450’ & ‘KX450’ but have only managed to print the whole message in upper using message.upper

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

You can use the method upper inside the brackets.

message = f"I would love to own a {dirtbike[0].upper()}! As well as a {dirtbike[1].upper()}!"

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading