Question

Write a while loop that repeatedly asks the user for a number until exactly 3 odd...

Write a while loop that repeatedly asks the user for a number until exactly 3 odd numbers have been given. (Python)

0 0
Add a comment Improve this question Transcribed image text
Answer #1

code screenshot:

sample output:

code :

countOdd=0 # a variable for storing count of odd number entered so far

while(1):

   x=int(input("enter a number\n")) # prompting user to enter a number
  
   if( x%2 == 1): # checking if the number entered is odd or not if odd then incrementing the count of odd
       countOdd+=1
  

   if( countOdd == 3): # checking count of odd is equal to 3 or not
       break

**please upvote

Add a comment
Know the answer?
Add Answer to:
Write a while loop that repeatedly asks the user for a number until exactly 3 odd...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT