Samuel Cooper Samuel Cooper - 1 year ago 46
Python Question

How do I get this code to print one single object and not three?

I would like to get help with this code, it's python.

import random
materials=['metal','paper','water']
for value in materials:
random.shuffle(materials)
print materials[0]

Answer Source

Your code works correctly. You may have an indentation error.
Try

import random
materials=['metal','paper','water']
for value in materials:
    random.shuffle(materials)
print materials[0]