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 to process capitalisation in words

I tried to solve this problem but don’t know how to, I would appreciate it if you could help me.

criteria:
If the paint colour label contains the string ‘blue’ with any capitalisation, your program should say: ‘Excellent! We’ll soon have enough paint for the sky!’

I need to know how how to make the code register the capitalisation of the word ‘blue’

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

colour = input ('Which colour did you find? ')
number_of_tins = int(input('Number of tins: '))
if 'blue' in colour:
  print ("Excellent! We'll soon have enough paint for the sky!")

thank you

>Solution :

Strings have a few methods to help you out, namely lower and upper. Typically lower is used in cases like this. It returns a new string of each letter in lowercase or uppercase respectively. So you can simply compare ‘blue’ to colour.lower()

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