0
Getting an error for assigning A...
Could someone please tell me how to assign the variable in this case? Code stars here: #could youll pleasw tell me whats the mistake in her? (Except for the square brackets) #thanks! print("Let\'s play a quiz!\n") print("Q1) What is the biological term for the tructure connecting bones to muscles in the human body?\n") ans1=["tendon","Tendon","Tendon.","tendon." A=input(string("Enter Answer 1 here: ")) If A in ans1: print("correct") else: print("Start studying bio bro! Youre wrong) ***Code ends here****
5 Answers
+ 2
print("Let\'s play a quiz!\n")
print("Q1) What is the biological term for the tructure connecting bones to muscles in the human body?\n")
ans1=["tendon","Tendon","Tendon.","tendon."]
A=input("Enter Answer 1 here: ")
if A in ans1:
print("correct")
else:
print("Start studying bio bro! Youre wrong")
ans1 needed a ] at the end
indents on your if/else statements needs to be 4 spaces.
input doesn't need to be declared a string, input is a string by default. When you do declare input as something else, the type goes around the input. Like this.... int(input("Enter A Number"))
also, instead of checking both Tendon and Tendon, you can check A.lower() or A.upper(). Like this..
if A.lower() == tendon:
This will work reguardless if they enter TENDON, Tendon, tendon, TeNdOn, etc
+ 1
read my notes above.
ans1=["tendon","Tendon","Tendon.","tendon."
You need a ] to close this line ^ .. Since You don't close it, it is looking at variable A and finding a problem because that's the next thing.
you also have a single space before A, there should be none
A = input("Enter Answer 1 here: ")
You have 2 spaces before if and else, there should be none. You have 3 spaces before your print statements in your if/else arguments. there should be 4.
If A in ans1:
print("correct")
else:
print("Start studying bio bro! Youre wrong)
+ 1
Worked perfectly thanks!!!! Started coding 2 days ago! Man it's tougher than I thought!
0
No problem. keep it up, it gets easier!