Samuel Cooper Samuel Cooper - 5 months ago 8
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

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]