I am learning Python, and having a hard time understanding variable scope. I built a list to store all the 52 cards in a deck of cards.
I am working on a second function that shuffles the cards into a random order w/ random. My problem is that the original list I built is OUT of the scope of the second function, so I cannot call that list and make a copy. I also want to use .extend not copy. How do I get this back in scope to be able to make a copy inside the second function?
Current OUTPUT: ERROR - ReportUndefinedVariable
Expected OUTPUT: a copy of my original list in a new function that I can then apply random to change the order of the deck.
Here is my code (still learning, so a lot of repetitive variables/lists/etc. Will refactor after I figure this out).
def create_deck():
    card_faces = []
    card_deck = [] 
    face = ['T', 'J', 'Q', 'K', 'A'] 
    suites = ['s', 'h', 'd', 'c'] 
    orig_list = [] 
    # run random through suites
    for i in range(2, 10): # --> THIS IS looping from 2-> 10 and appending it to card_faces.
        card_faces.append(str(i))
    for j in range(5): # --> this is looping through the 4 face cards TJQKA
        card_faces.append(face[j])
    for k in range(4): # --> this is looping through the 4 suites and then it adds the faces to the suites.
        for n in range(13):
            card = (card_faces[n] + suites[k])
            card_deck.append(card)
    
    for m in range(52):
        #print(card_deck[m])
        orig_list.append(card_deck[m])   
    #print(orig_list)
    print(card_deck)
Here is the new function I am creating to copy list:
def copy_lst(list):
    copy = []
    copy.extend(list)
    return copy
extended_copy = copy_list(orig_list)
 
     
    