anonymous
  • anonymous
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!)
MIT 6.189 A Gentle Introduction to Programming Using Python (OCW)
jamiebookeater
  • jamiebookeater
I got my questions answered at brainly.com in under 10 minutes. Go to brainly.com now for free help!
At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.

Get this expert

answer on brainly

SEE EXPERT ANSWER

Get your free account and access expert answers to this
and thousands of other questions

andrew.m.higgs
  • andrew.m.higgs
Hi 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
  • anonymous
@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)
andrew.m.higgs
  • andrew.m.higgs
Pleasure. :-)

Looking for something else?

Not the answer you are looking for? Search for more explanations.

More answers

Looking for something else?

Not the answer you are looking for? Search for more explanations.