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 trialARUN DAMODARAN
733 PointsWhile loop challenge
While loops does not exit in the below case and it still shows the message when the user response is "no"
name = input("Whats your Name? ")
usr_resp = input("{}, do you understand python while loops? \nEnter yes/no ".format(name))
while usr_resp != "yes":
print("ok, {}, while loops in Python repeat as long as a certain Boolean condition is met.".format(name))
user_resp = input("{}, now do you understand python while loops? \nEnter yes/no ".format(name))
print("That's great, {}. I 'm please that you understand while loops now. That was getting repetitive".format(name))
1 Answer
boi
14,242 PointsYou have an indentation error and a typo in your code.
It seems that the last line of code is in your while loop, indent it out of the while loop
as for the typo, you wrote usr__resp in one place and user_input in another.
fixed version;
name = input("Whats your Name? ")
user_resp = input("{}, do you understand python while loops? \nEnter yes/no ".format(name))
while user_resp != "yes":
print("ok, {}, while loops in Python repeat as long as a certain Boolean condition is met.".format(name))
user_resp = input("{}, now do you understand python while loops? \nEnter yes/no ".format(name))
print("That's great, {}. I 'm please that you understand while loops now. That was getting repetitive".format(name))