<html><body><div style="color:#000; background-color:#fff; font-family:times new roman, new york, times, serif;font-size:12pt"><div>As far as I understood, this shouldn't be possible. this is python 2.7<br></div><div><br></div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: times new roman,new york,times,serif; background-color: transparent; font-style: normal;">weirdness is in deal() at the end<br></div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: times new roman,new york,times,serif; background-color: transparent; font-style: normal;"><br></div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: times new roman,new york,times,serif; background-color: transparent; font-style: normal;">################################################<br></div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: times new roman,new york,times,serif; background-color: transparent; font-style: normal;"><br></div><div
style="color: rgb(0, 0, 0); font-size: 16px; font-family: times new roman,new york,times,serif; background-color: transparent; font-style: normal;">import random<br><br>class card:<br> def __init__(self, suit, rank, name):<br> self.suit = suit<br> self.rank = rank<br> self.name = name<br> <br><br>def makedeck():<br> #creates an ordered deck of card objects<br> #ranks are clumped (four 2's, four 3's etc)<br> <br> suits = ['Spades', 'Diamonds', 'Clubs', 'Hearts']<br> ranks = []<br> for x in range(2, 15):<br> ranks.append(x)<br><br> names = ['Two', 'Three', 'Four', 'Five', 'Six', 'Seven', 'Eight', 'Nine',
'Ten', 'Jack', 'Queen', 'King', 'Ace']<br><br> stack = []<br><br> for rank in ranks:<br> for suit in suits:<br> name = names[rank - 2]<br> stack.append(card(suit, rank, name))<br><br> return stack<br><br><br>def deal(quantity):<br> <br><span style="color: rgb(127, 127, 0);"> hand = []<br> for cards in range(0, quantity):<br> hand.append(deck.pop())<br> return hand</span></div><div style="color: rgb(127, 127, 0); font-size: 16px; font-family: times new roman,new york,times,serif; background-color: transparent; font-style: normal;"><br></div><div style="color: rgb(127, 127, 0); font-size: 16px; font-family: times new
roman,new york,times,serif; background-color: transparent; font-style: normal;"><span style="color: rgb(0, 0, 0);">#################################################</span></div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: times new roman,new york,times,serif; background-color: transparent; font-style: normal;"><br><span style="color: rgb(0, 0, 0);"></span></div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: times new roman,new york,times,serif; background-color: transparent; font-style: normal;"><span style="color: rgb(0, 0, 0);">#if you run this and do:</span></div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: times new roman,new york,times,serif; background-color: transparent; font-style: normal;"><br><span style="color: rgb(0, 0, 0);"></span></div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: times new roman,new york,times,serif; background-color: transparent; font-style:
normal;"><span style="color: rgb(0, 0, 0);">deck = makedeck()</span></div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: times new roman,new york,times,serif; background-color: transparent; font-style: normal;"><span style="color: rgb(0, 0, 0);">hand = deal(5)</span></div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: times new roman,new york,times,serif; background-color: transparent; font-style: normal;"><br><span style="color: rgb(0, 0, 0);"></span></div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: times new roman,new york,times,serif; background-color: transparent; font-style: normal;"><span style="color: rgb(0, 0, 0);">#and then finally</span></div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: times new roman,new york,times,serif; background-color: transparent; font-style: normal;"><br><span style="color: rgb(0, 0, 0);"></span></div><div style="color: rgb(0, 0, 0); font-size: 16px;
font-family: times new roman,new york,times,serif; background-color: transparent; font-style: normal;"><span style="color: rgb(0, 0, 0);">len(deck)</span></div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: times new roman,new york,times,serif; background-color: transparent; font-style: normal;"><br><span style="color: rgb(0, 0, 0);"></span></div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: times new roman,new york,times,serif; background-color: transparent; font-style: normal;"><span style="color: rgb(0, 0, 0);">#we find that the global deck has been modified within the deal() function without </span>including</div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: times new roman,new york,times,serif; background-color: transparent; font-style: normal;"><br></div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: times new roman,new york,times,serif; background-color: transparent; font-style:
normal;">global deck</div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: times new roman,new york,times,serif; background-color: transparent; font-style: normal;"><br></div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: times new roman,new york,times,serif; background-color: transparent; font-style: normal;">#within the deal() function</div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: times new roman,new york,times,serif; background-color: transparent; font-style: normal;"><br></div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: times new roman,new york,times,serif; background-color: transparent; font-style: normal;">#it seems insane to me that it's possible to alter global variables within functions without declaring global or passing the variable in as an argument.<br></div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: times new roman,new york,times,serif;
background-color: transparent; font-style: normal;"><br></div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: times new roman,new york,times,serif; background-color: transparent; font-style: normal;"><br></div></div></body></html>