二手产品经理

二手产品经理

THIS IS RENO

Learn Python online for 100 days - Week 2, Day 5

Record#

Today's practice is to troubleshoot errors. With the modern way of troubleshooting errors, I think it should be relatively simple, after all, we have the big tool called chatgpt, hahaha!

  1. I don't know why there is a red underline error prompt on line 16 in replit, but there is no problem when executing it. Maybe it's because of the emoji?

  2. The debugging went smoothly, except for the if else elif part where I had to think for a moment. In the correct answer, print() is also acceptable, no need for "".

CODE#

print("100 Days of Code QUIZ")
print("") # I guess this is to print a new line, printing nothing should work.
print("How many can you answer correctly?) # Missing quotation marks
ans1 = ("What language are we writing in?") # Missing input
if ans1 == "python":
  print("Correct")
else:
  print("Nope🙈 # Missing quotation marks
ans2 = input("Which lesson number is this?") # It's a number, should be defined as int
if(ans2>12):
print("We're not quite that far yet") # Indentation
else:
  print("We've gone well past that!")
elif(ans2==12): # This elif should be after if, not after else.
  print("That's right!")

Modified code#

print("100 Days of Code QUIZ")
print("")
print("How many can you answer correctly?")
ans1 = input("What language are we writing in?")
if ans1 == "python":
  print("Correct")
else:
  print("Nope🙈") 
ans2 = int(input("Which lesson number is this?"))
if(ans2>12):
  print("We're not quite that far yet")
elif(ans2==12):
  print("That's right!")
else:
  print("We've gone well past that!")

Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.