Apr-04-2018, 02:37 PM
Lets make it easy, since the code is pretty repetitive, and look at the first option only.
Thus
One other point, all your 'input()s' on lines 6 thru 10 and the other segments as well, need only be 'print', having them as inputs requires the user to hit enter after every line, which I'm sure is not your intent.
name = input("Hello, what is your name?") print(name, ",welcome to the car quiz!") first_answer = 2 score = 0 input("Q1 - Which country does Porsche come from?") input("1 - England") input("2 - Germany") input("3 - Austria") input("4 - Portugal") user1 = input("Enter your answer:") if user1 == first_answer: score = score + 1 else: score = score + 0The main problem is you are trying to compare 'strings' with 'numbers' and the result will always be false. Note that you have defined 'score' and 'first_answer' as integers, while requesting from user1 a 'string' value. Remember, on it's own, the input() function returns a string. We can modify this behavior by telling the function what we want returned.
Thus
user1 = input("Enter your answer:")becomes
user1 = int(input("Enter your answer:"))Now your if/else statements will be comparing numbers with numbers.
One other point, all your 'input()s' on lines 6 thru 10 and the other segments as well, need only be 'print', having them as inputs requires the user to hit enter after every line, which I'm sure is not your intent.
If it ain't broke, I just haven't gotten to it yet.
OS: Windows 10, openSuse 42.3, freeBSD 11, Raspian "Stretch"
Python 3.6.5, IDE: PyCharm 2018 Community Edition
OS: Windows 10, openSuse 42.3, freeBSD 11, Raspian "Stretch"
Python 3.6.5, IDE: PyCharm 2018 Community Edition