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 Python Basics Functions and Looping While Loops

Feedback if any

name = input("What's your name? ") print("{}, do you understand Python while loops?".format(name)) answer = input("Enter Yes/No: ")

while answer != 'Yes': if answer == 'No': print("Well, {}, while loops in Python repeat as long as a certain Boolean condition is met.".format(name)) answer = input("{}, now do you understand Python while loops?\nEnter Yes/No".format(name)) elif answer != 'Yes' or 'No': answer = input("Invalid answer. Try again...\nEnter Yes/No")

print("That's awesome, {}. I'm pleased that you understand while loops now. Let's move on.".format(name))

HEY: Just want to make sure it's readable. Thanks. -_-

1 Answer

Somewhere at the bottom of the page it says 'Markdown Cheatsheet' which shows you how to add code to the question like this:

name = input("What's your name? ")
print("{}, do you understand Python while loops?".format(name))
answer = input("Enter Yes/No: ")
while answer != 'Yes':
    if answer == 'No':
        print("Well, {}, while loops in Python repeat as long as a certain Boolean condition is met.".format(name))
        answer = input("{}, now do you understand Python while loops?\nEnter Yes/No".format(name))
    elif answer != 'Yes' or 'No':
        answer = input("Invalid answer. Try again...\nEnter Yes/No")
print("That's awesome, {}. I'm pleased that you understand while loops now. Let's move on.".format(name))

Basically, you put 3 backticks and the language at the start, and 3 backticks at the end. Hope this helps!

P.s, you could maybe add something like:

while answer.upper() != 'YES':

so that it doesn't matter if they enter in lower or upper case? Apart from that I can't see any problems, but I'm a noob lol.

Jeff Muday
Jeff Muday
Treehouse Moderator 28,722 Points

I changed your comment to an answer and upvoted. Even though you say you're a noob, you answer like a Pro!

Keep up the good work Robert!