A community for students.
Here's the question you clicked on:
 0 viewing
anonymous
 4 years ago
Ex 1.8 (pt.4) I can't figure out how to stay IN a while loop on an incorrect input by the user. I kept having the loop stop, or go on for ever. In the end i just used a recursive function! (but we've not covered functions yet..so thats a bit like cheating!)
anonymous
 4 years ago
Ex 1.8 (pt.4) I can't figure out how to stay IN a while loop on an incorrect input by the user. I kept having the loop stop, or go on for ever. In the end i just used a recursive function! (but we've not covered functions yet..so thats a bit like cheating!)

This Question is Closed

andrew.m.higgs
 4 years ago
Best ResponseYou've already chosen the best response.3Hi there, What i did was to set a variable equal to 1 and then took user input into that var. Then my while loop was simply: while var % 2 != 0: var = input ("please type an even number : ") Hope this helps.

anonymous
 4 years ago
Best ResponseYou've already chosen the best response.0@andrew.m.higgs Thanks Andrew. Worked just fine! I couldn't quite get my head around looping back upon a False input. I kept thinking "surely it needs another condition to test against?" But your reply showed me how simple it was! :0)
Ask your own question
Sign UpFind more explanations on OpenStudy
Your question is ready. Sign up for free to start getting answers.
spraguer
(Moderator)
5
→ View Detailed Profile
is replying to Can someone tell me what button the professor is hitting...
23
 Teamwork 19 Teammate
 Problem Solving 19 Hero
 Engagement 19 Mad Hatter
 You have blocked this person.
 ✔ You're a fan Checking fan status...
Thanks for being so helpful in mathematics. If you are getting quality help, make sure you spread the word about OpenStudy.