Python Forum
problems with random number/string
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
problems with random number/string
#4
Python is called zero-indexed. So the first item in a list or string has the index of zero, the second item has an index of one, and so on. So my early code was a little off. If you put a zero at the beginning of your ranks list, and use random.randint(2, 14), it should work pretty well.
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply


Messages In This Thread
RE: problems with random number/string - by ichabod801 - Mar-01-2019, 06:00 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Sample random, unique string pairs from a list without repetitions walterwhite 1 446 Nov-19-2023, 10:07 PM
Last Post: deanhystad
Question Extracting Version Number from a String britesc 2 1,083 May-31-2023, 10:20 AM
Last Post: britesc
  find random numbers that are = to the first 2 number of a list. Frankduc 23 3,177 Apr-05-2023, 07:36 PM
Last Post: Frankduc
  TypeError: float() argument must be a string or a number, not 'list' Anldra12 2 4,837 Jul-01-2022, 01:23 PM
Last Post: deanhystad
  matrix number assignement to the random indices juniorcoder 4 1,913 Feb-19-2022, 02:18 PM
Last Post: juniorcoder
  generating random string unique forever Skaperen 5 2,322 Aug-20-2021, 07:15 AM
Last Post: Gribouillis
  Generate random hex number ZYSIA 1 11,504 Jul-16-2021, 09:21 AM
Last Post: DeaD_EyE
  TypeError: int() argument must be a string, a bytes-like object or a number, not 'Non Anldra12 2 5,179 May-02-2021, 03:45 PM
Last Post: Anldra12
  cursor.execute: How to insert dynamic number in a string? stoeberhai 2 3,487 Mar-18-2021, 12:55 PM
Last Post: stoeberhai
  Regular expression: cannot find 1st number in a string Pavel_47 2 2,406 Jan-15-2021, 04:39 PM
Last Post: bowlofred

Forum Jump:

User Panel Messages

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