Forums

Help with lists

Hi everyone, I'm new to python but trying to assign 5 cards to 2 players using lists.. I have created the below code so far but I can't figure out why it's not working:

# #Create a deck of cards
faces = ["2 ", "3 ", "4 ", "5 ", "6 ", "7 ", "8 ", "9 ", "10 ", "J ", "Q ", "K ", "A "]
suits = ["spades", "clubs", "hearts", "diamonds"]
cards = []

#loop through faces
cards = [f + s for f in faces for s in suits]

#loop through suits
cards[:4], cards[-4:]

#shuffle the cards
import random
random.shuffle

hand_1 = []
hand_2 = []

while len (hand_1) < 5:

while len (hand_2) < 5:

#print outcome
print(*cards, sep="\n")

[edit by admin: formatting]

Hi there -- these are the forums for PythonAnywhere, an online Python coding and web-hosting environment; while there may be users of our site that can help you with general Python programming questions, you might be better off asking on a general programming Q&A site like Stack Overflow.