import random
wordlist = {'Candy', 'Monkey'}
level = 0
while level == 0:
number = random.randint(1, 2)
if number == 1:
print 'Candy'
secword = 'Candy'
level = 2
elif number == 2:
print 'Monkey'
secword = 'Monkey'
level = 2
for i in secword:
print i
I have a couple of questions about the code I just randomly wrote (I'm a beginner)
1) How do I assign a word in a list to a variable? ex. assign the word 'Candy' into a variable because I always get the error (List is not callable)
2) How do I assign the variable i (in the for loop) to a separate variable for each letter?
Thanks! Tell me if it's not specific enough.
random.choice(). This whole thing can be reduced to about 4 or 5 more Pythonic lines.for c in list(random.choice(["Candy","Monkey"])): print c:)