I can't seem to get this working. I've got a loop for a simple card game of higher or lower, and what I'd like to do, is return the card or any values of the card, and the points so that I can pickle them for storage and play this game over and over. But, I can only return the card and points in the first iteration of the loop. Whenever the gameloop function is called within the function again, the print function on the very last line prints None.
def gameloop(rand_card, rand_type, point):
point = point
card = rand_card, rand_type
print("The card is:")
print_card(card[0], card[1])
print("Do you bet on a higher or lower value to be drawn? (H/L)")
ans = input().lower()
if ans == "q":
return card, point
new_card = random_card(), random_type()
print("The new card is:")
print_card(new_card[0], new_card[1])
if ans == "h":
if new_card[0] > card[0]:
print("Congratulations, the new card was higher. You have been awarded one point.")
point += 1
elif new_card[0] < card[0]:
print("Sorry, the new card was lower. One point has been deducted.")
point -= 1
else:
print("It's a tie! No points deducted.")
elif ans == "l":
if new_card[0] < card[0]:
print("Congratulations, the new card was lower. You have been awarded one point.")
point += 1
elif new_card[0] > card[0]:
print("Sorry, the new card was higher. One point has been deducted.")
point -= 1
else:
print("It's a tie! No points deducted.")
print("You have a total of {} points.".format(point))
gameloop(new_card[0], new_card[1], point)
data = gameloop(random_card(), random_type(), 0)
print(data)