N
N
nonamefromzp2020-04-28 11:17:25
Python
nonamefromzp, 2020-04-28 11:17:25

Can't figure out functions in Python?

Hello, I'm new, I couldn't find a solution to one simple problem.
It is necessary that while the user enters numbers less or more than 3, the number input is displayed again. But the problem is that if you initially enter an incorrect number, and the second time it is correct, then after the second time the number is displayed again. If you enter the wrong number two or more times, then for the third and more times everything will work fine, and the code will continue to run. I apologize for the idiotic wording of the question.

def fun():
    return int(input())

a = fun()

while a < 3 or a > 3:
  fun()
  a = fun()

Answer the question

In order to leave comments, you need to log in

1 answer(s)
T
Timur Pokrovsky, 2020-04-28
@nonamefromzp

1. Why ? why not ? 2. Why call a function 2 times in a loop? a < 3 or a > 3a != 3

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question