0
Ptarget = int(input("What is your target amount of points to achieve?"))
while Ptarget != int:
    print("You have not provided a valid input, please try again.")
    Ptarget = int(input("What is your target amount of points to achieve?"))

How do I make it so the while loop functions, by asking the user for another input if the previous was not an integer, without breaking the program?

clcto
  • 9,530
  • 20
  • 42
Ynnekb55
  • 35
  • 1
  • 7

1 Answers1

0

Use an exception

while True:
    try:
        Ptarget = int(input("What is your target amount of points to achieve?"))
        break
    except:
        print("You have not provided a valid input, please try again.")
Paul Rooney
  • 20,879
  • 9
  • 40
  • 61