Error: 'int' object is not iterable'



  • My code is:

    guess_me = 5
    for number in int(guess_me):
        if number < guess_me:
            print('too low')
        elif number == guess_me:
            print('found it!')
            break
        elif number > guess_me:
            print('oops')
            break
    

    Text of task: Apply 5 variable guess_me. Use the cycle for to be tested with a variable number over range(10). If the value of the variable number is less than the value of guess_me, take it out. on the screen message 'too low'. If it equals the meaning of guess_me, get it out. "found it" and then get out of the cycle. If variable value number more than guess_me, put a message on the screen 'oops' and get out. from the cycle.



  • for number in int(guess_me):
                  ^^^^^^^^^^^^^
    

    Replace:

    for number in range(10):
    
              ^^^^^^^^^
    

    And then it will be strictly in line with the mission: number by range range(10)"


Log in to reply
 

Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2