Adding items to the list in the list

I have created a code for the exercise that deals 5 cards to 5 players. The cards are to be dealt to the list in the “players” list. I created a while loop in a while loop. This is where my problem comes in: each loop is only performed once and each player is dealt only one card. What is wrong?

import random

amountCards = 5

def dealCards(playerCards):
    try:
        len(cards) > 0
        playerCards.append(cards.pop())
    except:
        return False
        
cards = ["9", "9", "9", "9",
            "10", "10", "10", "10",
            "Jack", "Jack", "Jack", "Jack",
            "Queen", "Queen", "Queen", "Queen",
            "King", "King", "King", "King",
            "Ace", "Ace", "Ace", "Ace",
            "Joker", "Joker"]
players = [
            [],
            [],
            [],
            [],
            [],

            ]

random.shuffle(cards)
i=0
a=0

while (i < amountCards):
    while (a < 5):
        dealCards(players[a])
        a+=1
    i+=1


if  len(players) == amountCards:
    for x in players:
        print(*x, sep=", ")
else:
    print ("There were not enough cards for the players")

Earlier I solved this problem with just one while loop and calling a function for each list in the list “players”.

i=0
 
while (i < iloscKart):
    dealCards(players[0])
    dealCards(players[1])
    dealCards(players[2])
    dealCards(players[3])
    dealCards(players[4])
    i+=1

But I guess that it can be shorten this code. Thanks for the tips

Answer

The second while loop only runs once because once it reaches 5, it needs to be reset back to zero.

Try this:

while (i < amountCards):
    a = 0
    while (a < 5):
        dealCards(players[a])
        a+=1
    i+=1