Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
While loop keeps looping
#2
random.sample will return list, in your case - list with just one element. You are comparing list with int - never True.
You want to use random.randint(1, 99) - https://docs.python.org/3/library/random...om.randint
or random.choice(range(1, 100))
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply


Messages In This Thread
While loop keeps looping - by mcoliver88 - Jul-29-2020, 12:33 PM
RE: While loop keeps looping - by buran - Jul-29-2020, 12:47 PM
RE: While loop keeps looping - by mcoliver88 - Jul-29-2020, 12:47 PM
RE: While loop keeps looping - by buran - Jul-29-2020, 12:48 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  "while" loop is looping back too early mangurian 1 1,399 Jan-28-2022, 09:15 AM
Last Post: ibreeden
  Nested for loop not looping puttingwordstogether 0 1,807 Jun-16-2020, 11:15 PM
Last Post: puttingwordstogether
  while loop will not stop looping TheTechRobo 5 3,985 Apr-20-2020, 01:47 PM
Last Post: TheTechRobo
  'Looping' does not work out within a 'for Loop' Placebo 4 3,595 Sep-15-2018, 08:19 PM
Last Post: Placebo
  For looping over a list, editing the list from inside the loop? Krookroo 3 4,131 Sep-04-2017, 05:08 PM
Last Post: Krookroo

Forum Jump:

User Panel Messages

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