Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

Why is my "print (count) not working, my program is below, I am learning python.

+2 votes
asked May 2, 2023 by Jericho (180 points)
name = input("what is your name?")
print ("hello",name,", prepare for a quiz.")
count = 1
question1 = 1
question2 = input("what is a dog? 1:four legged mammal that is commonly adopted as pets. 2: reptile with no legs")
if question1 == question2:
    count = count + 1
else:
    count = count - 1
print (count)

3 Answers

+1 vote
answered Jun 6, 2023 by StormIV (180 points)
When you take the input for question 2, it is a string. So when you do if question1 == question 2, it won't ever be true, because question1 is a variable.

If you want the string to be converted to a variable use the int() function (int stands for integer). So it would like like this: question2 = int(question2).
0 votes
answered Jun 6, 2023 by Vasanthakumar A (140 points)
'''

name = input("what is your name?")
print ("hello",name,", prepare for a quiz.")
count = 1
question1 = 1
question2 = int(input("what is a dog? 1:four legged mammal that is commonly adopted as pets. 2: reptile with no legs")) #you want to which data types for that variable the default data type is string so it is not matched.
if question1 == question2:
    count = count + 1
else:
    count = count - 1
print (count)
0 votes
answered Jun 6, 2023 by Lyrics (190 points)

question1 is int, question2 is string so it always false when u compare. U just convert question2 to int like:

question2 = int(input("what is a dog? 1:four legged mammal that is commonly adopted as pets. 2: reptile with no legs"))

Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...