Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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 26,972 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!