Skip to content

Instantly share code, notes, and snippets.

Created August 10, 2017 19:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save anonymous/61b4f486c38a47fc48bf488335c5127b to your computer and use it in GitHub Desktop.
Save anonymous/61b4f486c38a47fc48bf488335c5127b to your computer and use it in GitHub Desktop.
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