replit

Before you start this course, you must login to Replit

If you have forgotten your Replit account user name or password, ask your Coder Coach.

CoderSports


Investigate

The ‘investigate’ stage gives students some example code and asks them questions about it to check their understanding. I use the block model to plan my questions. Try it, it’s really useful.


Changing Case

Convert all characters to CAPS

string.upper()

Convert all characters to lower case

string.lower()

These two functions are useful to get Python to ignore case. When getting a user input, use either the upper() or lower() method to convert that string to uppercase or lowercase. Then compare it to an either upper or lower case string.

This is an example use case where case does not matter.

print("What's the best school subject?")
answer = input()
answer = answer.upper()

# Now the user input is all uppercase and can be easily compared to the next line.

if answer == "COMPUTER SCIENCE":
  print("You betcha!")
else:
  print("I think you made a mistake, it's spelled 'Computer Science'")

Help! My Code Does Not Work!

  • .upper() or .lower() are immediately after the string or variable with no space between.
  • .upper() or .lower() have the . before and brackets after.

Hints