Python:
import random
a = [1,2,3]
random.shuffle(a)
print(a)
print(a[0])
def fun1():
print("I'm function 1!")
def fun2():
print("I'm function 2!")
def fun3():
print("I'm function 3!")
fun(a[0])
This is a simplified version of a deck of cards hence the odd random selection. Is there a way to modify the code above in order to get my expected outcome? (if a == 2 then fun2() would be called)
Python:
def deal():
global p_hand
global d_hand
p_hand = deck[0] + deck[1]
d_hand = deck[2] + deck[3]
print("player's" ,deck[0],deck[1], "vs dealer's" ,deck[2] )
if d_hand == 21:
elim()
if deck[2] == 2:
d2()
if deck[2] == 3:
d3()
if deck[2] == 4:
d4()
if deck[2] == 5:
d5()
if deck[2] == 6:
d6()
if deck[2] == 7:
d7()
if deck[2] == 8:
d8()
if deck[2] == 9:
d9()
if deck[2] == 10:
d10()
if deck[2] == 11:
d11()
This is my current solution which seems quite long and inelegant