Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python

I can't get my if statement to evaluate to false

I am trying to make a quiz program. I want this quiz program to test Kanji (Japanese characters). I wrote this code:

question = input("What's the kanji for GO?" ) kanji = ["行く"]

if kanji == True: print("thats correct!") else: print("Try again!")

as soon as I wrote it I knew that it will always evaluate to True. How can I make it so when I type out the kanji >>行く on the input it will check if it's correct and print "That's correct" or if I type something else it will say "Try again". I would appreciate any help. Thank you.

1 Answer

Jason Anders
MOD
Jason Anders
Treehouse Moderator 145,858 Points

Hi There,

For the if statement, you want to compare the input to the value in the variable. So something along the lines of

if question == kanji:

This will evaluate the value of the input against the value stored in the variable. If they match, it returns True.

Hope that helps.

:) :dizzy:

Thank you so much! That makes so much sense when I look at it. I can't believe I didn't think of it. I really appreciate your quick response.