Python Forum
Sorting ID with first and last name Arrays
Thread Rating:
  • 2 Vote(s) - 2.5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Sorting ID with first and last name Arrays
#2
I don't know what min2max list was but hopefully it wasn't important ^_^. Maybe I'm starting to get sleepy.
for a random_id you could put a for loop that will put a random int for every name in firstname list. 
I put a counter 

list_size = len(firstName)
random_id = [random.randint(10,99) for x in range(list_size)]
student_data =[]
counter = 0
Then all you need is another loop and to append data to a list. 
using the counter and format function you can get your desired result

 student_data.append("{} {} {} ".format(random_id[counter],firstName[counter],lastName[counter]))
 counter += 1
My results:
12 Debby Rahman 
15 Tom Ulch 
20 Tobi Bombino 
29 Annamma Shultz 
30 Manny Ryan 
30 Patti Rahman 
48 Anna Zenoff 
48 Kenneth Black 
51 Norma Ayala 
57 Michael Franco 
64 Jim Hooper 
70 Lusan Zenoff 
71 Paige Braun 
73 Teresa Kuawata 
85 Val Umeda 
87 Maggie Perdue
Reply


Messages In This Thread
RE: Sorting ID with first and last name Arrays - by smbx33 - Apr-23-2017, 10:54 AM

Forum Jump:

User Panel Messages

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