Day 012 - Project 12 : I've broken some code!

If you have any questions, comments or issues with this project please post them here!

Hmmm. I actually did not fix the code the way the answer suggested. i could not remember the correct syntax for integers in the input statement BUT, i did get the code to work by changing the integer into a string so, i guess that’s one more way to skin a cat?!
here’s what I did vs. what the answer actually was.
My 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 = 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!”)

Replit’s answer:
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!”)

Hey @socraticmudd, welcome to the forums!

Could you explain whats the problem you are having with you code?

Hi @socraticmudd

In addition to @hugoondev 's welcomes I wanted to ask for some more information here.

In order for the community to suggest ideas to help you solve your code issue it would be useful to share a link to your Repl, not post your entire code in the message as it is difficult to see if there are indentation errors etc.

Any error messages that you see appear when you attempt to run your code would also be useful to share here.

1 Like

Hello Hugo,
I guess I didn’t really have a problem as much as the solution i came up with worked but, was actually inaccurate according to Replit. I changed the integer ‘12’ to a string by inserting quotes around it when i should have used: ans2 = int(input(“Which lesson number is this?”)). I could not remember whether the ‘int’ syntax was supposed to go after the ‘input’ syntax or where the parenthetical s were supposed to go so, I improvised. I am only on day 12 but, do the future lessons offer a reminder of some of the code we have learned so far or should we rely on notes?

1 Like

As you said earlier, there are multiple ways to skin a cat. So if it works and doesn’t lead to unexpected issues, then great! You have learned :partying_face:
As you learn more you might see how one way is better, or more efficient, or simple clearer, or…

Future lessons offer a few reminders, but mostly it is up to you to search for the answers (gets better into your head that way).

2 Likes

I don’t know, maybe it could happen!

Not going to lie I took little help. But here’s the answer

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!")
1 Like

On it says that there is a syntax error. The Repl is running perfectly fine though.

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 = input("Which lesson number is this?")
if(int(ans2)>12):
  print("We're not quite that far yet")
elif(int(ans2)==12):
  print("That's right!")
else:
  print("We've gone well past that!")

The syntax error is at the end of print("Nope"). However, it is a completely valid line of code (in my terms).

When I run that code I get no errors.

1 Like

There is a red mark right below the end of the parathense on my screen.

I dont get it. Try refreshing

image

1 Like

i think its an issue with replit. i get same error some times valid code but random red dots. usually deleting and retyping works

doesn’t effect functionality though so unless he didn’t try to run it that not the issue

1 Like