I am trying to write a function that does the following:
If player_hand doesn't have any number that is less than or equal to mana_bank the function should do nothing.
If player_hand has a number that is less than or equal to mana_bank then the function should prompt the user with which number he chooses.
If the number the user chooses is less than mana_bank it should return a list with that number. If the number is more than mana_bank it should call the function again untill he prompts a number that is less than or equal to mana_bank.
Whenever I run the function and the user first prompts a number that is higher than mana_bank the function gets called from within itself, and then even if the user prompts a number lower than or equal to mana_bank, the function returns None instead of the number in a list.
I also tried making the variable player_choice global but it still didn't work.
Would appreciate any guidance.
def pick_card():
    player_choice_str = 0
    player_choice = []
    for i in player_hand:
        if i <= mana_bank:
            print(player_hand, mana_bank, "Mana available type the name of the card you wish to play ... ")
            player_choice_str = input()
            break
        if not i <= mana_bank:
            return "You don't have enough mana to play a card."
    if int(player_choice_str) > mana_bank:
        print("That card costs " + str(player_choice_str) + " and you only have " + str(mana_bank) + " this round.")
        pick_card()
    if int(player_choice_str) <= mana_bank:
        player_choice.append(player_choice_str)
        return player_choice
player_hand = [4, 8, 8]
mana_bank = 4
print(pick_card())
 
     
    