Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Mystery Python code from G+
import random
list1 = ['a','b','c']
list2 = list1[:]
a_count = 0
b_count = 0
c_count = 0
def r_s():
global a_count
global b_count
global c_count
selected_letter = random.choice(list2)
if selected_letter =='a':
if a_count == 1:
print "no a"
list2.remove('a')
return r_s()
else:
print selected_letter
a_count += 1
return r_s()
elif selected_letter =='b':
if b_count == 1:
print "no b"
list2.remove('b')
return r_s()
else:
print selected_letter
b_count +=1
return r_s()
elif selected_letter =='c':
if c_count == 1:
print "no c"
list2.remove('c')
return r_s()
else:
print selected_letter
c_count += 1
return r_s()
else:
print "no letters"
print r_s()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment