-2
tries = 0
while True:
    try:
      imput = int(input("Input An Integer: "))
      if imput != 0:
      print(imput)
    except ZeroDivisionError:
        print("Bro what you doin?")
    except TypeError:
        print("Bruh What you doin?")
Tomerikoo
  • 15,737
  • 15
  • 35
  • 52
J Man
  • 1

1 Answers1

0

This should work:

With a boolean you can safe, whether an integer was given or not

got_int = False

As long as no integer was given, it waits for the next input

while got_int == False:

    try:
        user_input = int(input('Input an integer: '))
        got_int = True
    except:
        print("That's not an integer")

It seems to me that you are not so familiar with try except. If so, you can read more about it here

Tomerikoo
  • 15,737
  • 15
  • 35
  • 52
  • 1
    A more idiomatic, pythonic way to write such loop is using `while True:` and `break`ing once the condition is satisfied instead of using a "flag" variable – Tomerikoo Mar 22 '21 at 15:08