Share your repls and programming experiences

← Back to all posts
How many letters are in your name?
JordynCarroll (6)

How many letters do you have in your name? :P

Commentshotnewtop
WyattKinzer1 (2)

for when it asks for your name dont forget to put a space after the question mark in the code. it will make it look better and not smushed into the question. but this was pretty cool. ps, I make this mistake all the time to. :)

InvisibleOne (300)

cool, but like @Axrevyn said, you should use .lower()

Axrevyn (220)

Not to nitpick. It took a while for me to realize what len() did, so props to you.
But .lower() is your friend.
In short, any variable with .lower() attached to the end will be converted to all lowercase letters. Perfect if you want to keep things non-case sensitive.

Here's some example code:

feeling = input("How are you feeling?")
if feeling in ["good", "Good", "GOOD", "fine", "Fine", "FINE", "great", "Great", "GREAT"]:
  print("That's good!")

That's a little painful to read. But this version of the code:

feeling = input("How are you feeling?")
if feeling.lower() in ["good", "fine", "great"]:
  print("That's good!")

All you had to do was add .lower(). It's easy and it makes your code less cluttered (and it's easier to type).