I am very new to python and am learning it just for fun. I am attempting to use it for a small application that shuffles a string list. I need to get a list of about 50 last names in a random order. I tried doing

items = [thing1, thing2, thing3]
random.shuffle(items)

but it tells me i need to define every item in the list. I know there has got to be a way to do this, i just havent figured it out yet. Any suggestions?

I am very new to python and am learning it just for fun. I am attempting to use it for a small application that shuffles a string list. I need to get a list of about 50 last names in a random order. I tried doing

items = [thing1, thing2, thing3]
random.shuffle(items)

but it tells me i need to define every item in the list. I know there has got to be a way to do this, i just havent figured it out yet. Any suggestions?

>>> items = ['thing1', 'thing2', 'thing3']
>>> import random
>>> random.shuffle(items)
>>> items
['thing3', 'thing1', 'thing2']
>>>

Without the quotes Python thinks they are objects.

Sincef you are new to python, i suggest you take the tutorial here.

thanks a lot!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.