Rocket asks the new pilot, "Ready to dock?" The pilot types Yes with a capital Y. Rocket's program checks for "yes" and says the pilot is not ready.
"But I said yes!" the pilot calls over the radio. Raven looks at the check. "What do you notice about the first letter?"
Nova shows two words side by side: Yes and yes. "Would you like a hint? To Python, a big Y and a small y are different. You could make them match first."
upper makes a copy of a string in capital letters. lower makes a copy in small letters.
Write the string, a dot, the word, and empty brackets.
msg = "Docking at Bay 2" print(msg.upper()) print(msg.lower()) print(msg)
| The screen shows |
|---|
| DOCKING AT BAY 2 |
| docking at bay 2 |
| Docking at Bay 2 |
answer = "Yes"
if answer.lower() == "yes":
print("Cleared to dock")
else:
print("Please wait") | The screen shows |
|---|
| Cleared to dock |
answer.lower() turns Yes into yes before the check. Now YES, Yes and yes all work.
| answer holds | Does answer.lower() == "yes" give True? |
|---|---|
| "YES" | ? |
| "yes" | ? |
| "Yes!" | ? |
| "y" | ? |
name = "raven" name.upper() print(name)
shout = "go Team 4" print(shout.upper()) print(shout.lower()) loud = shout.upper() print(loud[0:2]) print(shout)
| answer holds | Does answer.upper() == "NO" give True? |
|---|---|
| "no" | ? |
| "No" | ? |
| "nope" | ? |
| "NO " (with a space at the end) | ? |
Nice work! Tomorrow you will search inside strings with in.