Python: Random item from list combining only two
I'm making a slot machine program in Python and for some reason, the random selector wants to combine a known two elements.
itmlist = random.choice(['banana', 'cherry', 'bar', 'seven', 'banana', 'cherry' 'banana', 'cherry', 'seven'])
print itmlist
It shows up as "cherrybanana" every once in a while and I am开发者_JAVA技巧 really confused.
You miss a comma between 'cherry' and 'banana' near the end of the list.
Python concatenate the strings so it becomes 'cherrybanana'
itmlist = random.choice(['banana', 'cherry', 'bar', 'seven', 'banana', 'cherry' 'banana', 'cherry', 'seven'])
精彩评论