Created
August 10, 2017 19:27
-
-
Save anonymous/61b4f486c38a47fc48bf488335c5127b to your computer and use it in GitHub Desktop.
Mystery Python code from G+
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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