Python Forum
Unexpected input in While Loop
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Unexpected input in While Loop
#1
Hi guys, I'm trying to learn how to do while loops and came across a problem. No errors show up in my code but when I run it, it doesn't ask the input in my while loop. It would be awesome if someone could help me figure this out. [python]
valid = {'1', '2', '3'}
while False:
advantage = input("Do you pick extra health [1], extra luck [2], or extra power [3[").strip()
if advantage in valid:
print("Your stats have been updated")
else:
print("Invalid input, try again")
break
[python]

Thank you for your consideration
Reply
#2
The you debug it

valid = {'1', '2', '3'}
print("before while")
while False:
    print("in while")  
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  WHILE LOOP NOT RETURNING USER INPUT AFTER ZerroDivisionError! HELP! ayodele_martins1 7 990 Oct-01-2023, 07:36 PM
Last Post: ayodele_martins1
  Code won't break While loop or go back to the input? MrKnd94 2 906 Oct-26-2022, 10:10 AM
Last Post: Larz60+
  WHILE Loop - constant variables NOT working with user input boundaries C0D3R 4 1,434 Apr-05-2022, 06:18 AM
Last Post: C0D3R
Exclamation question about input, while loop, then print jamie_01 5 2,615 Sep-30-2021, 12:46 PM
Last Post: Underscore
  I want to check if the input is str or is int & if it's str repeat the loop HLD202 4 2,719 Nov-23-2020, 11:01 PM
Last Post: perfringo
  Loop back through loop based on user input, keeping previous changes loop made? hbkpancakes 2 2,883 Nov-21-2020, 02:35 AM
Last Post: hbkpancakes
  if-loop does not respond to input Kmarstein 1 2,194 Jan-28-2020, 09:29 PM
Last Post: Larz60+
  Nested Loop for user input Ads 2 3,524 Dec-30-2019, 11:44 AM
Last Post: Ads
  How to Loop my calculator input Michael1 2 3,688 Dec-13-2019, 04:57 AM
Last Post: ICanIBB
  Server infinite loop input from user tomislav91 1 4,169 May-23-2019, 02:18 PM
Last Post: heiner55

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020