I am having trouble resetting the game so that the piles each start with 5 once
ID: 3748487 • Letter: I
Question
I am having trouble resetting the game so that the piles each start with 5 once the computer or the human wins. The game should end at 0 which it does but then the piles stay at 0 and the next game will end early because the piles are less than zero.
temp.py hello.py lab00 .py proj01. nteractiveshell.. | sitecustomize 19 pile_one int(5) 28 pile two int(5) 21 score ply int(e) 22 score_comp int(e) 23 print "Start-Pile 1: 5 Pile 2: 5" 24 if start int>1: 25 start strinput("Would you like to play?no, 1yes)" 26 start int int(start str) 27 while start int 1: 28 while pile one and pile two 0: Name Type pile int int1 pile one pilestr str1 piletoint score_comp int score ply int start int int start str str Size Value 29 pile str input("Choose a pile 1 or 2): ") pile_int intlpile_str) if pile intc1: 32 print("Pile nust be 1 or 2 and non-empty. Please try again." pile str input("Choose a pile (1 or 2): " pile int- int pile str) elif pile_int 2: 36 37 38 print("Pile nust be 1 or 2 and non-empty. Please try again. pile str input"Choose a pile (1 or 2): " pile int- int pile str) if pile-int=1; File explorer stone str input"Choose stones to renove from pile: " stone_num int(stone_str if stone nur>3: IPython consolo Console 1/A printl "Stones must be 1 to 3. Please try again." stone str input"Choose stones to remove from pile: " stone_nun int stone str) Pile1: 2 Pile 2: 0 Computer -> Remove 1 stones from pile 1 Pile 1 1 Pile 20 46 47 elif stone numc printl "Stones must be 1 to 3. Please try again." stone str- inputf"Choose stones to remove from pile: ") stone nu intstonestr) Choose a pile ( or 2: 1 pile onestone_num Choose stones to remove from pile: 1 Player-Remove 1 stones fron pile 1 Pile 1: 0 Pile 2: 0 Player wins! Score ->human: 1 computer: 8 elif pile int-2: stone str input("Choose stones to renove from pile: " stone_num int(stone_str) if stone nur 3: 56 57 58 print"Stones must be 1 to 3. Please try again." stone-str= input("Choose stones to remove from pile; "> stone_nu int(stone str) Would you like to play? (0 , 1eyes) 1 Start> Pile 1: 5 Pile 2: 5 elif stone numc-: print"Stones must be 1 to 3. Please try again." stone str- input"Choose stones to remove from pile: ") stone-num= int(stone-str) Choose a pile ( or 21: 2 Choose stones to remove from pile: 2 Player-Reove 2 stones fron pile 2 Pile 1: 0 Pile 2:-2 Conputer -> Remove 1 stones from pile 1 Pile 1 : 0 Pile 22 62 pile twostone_num 64 65 print("Player -> Remove",stone num, "stones from pile",pile int,) print "Pile 1: ",pile one,"Pile 2: ".pile two, if pile one and pile_two-0: print"Player wins!") score ply 1 print"Score -> human:",score ply,"; computer:",score comp) Traceback (most recent call last): 67 Python console History logExplanation / Answer
Before line 95 and 74, you need to put below lines:
pile_one = int(5)
pile_two = int(5)
If it still doesn't work properly, then please share your complete code on your g drive and i will surely help.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.