list - Python Text-Based Baseball Game - Flipping Booleans -


my friend , making text-based baseball game in python. trying figure out how manage runners on base. thinking if best way have list of booleans , flip them based on if play single, double, etc. appreciated! ex. bases = [false,false,false] if hit == single: bases = [true,false,false] finding difficult considering possible combinations of runners on base

from collections import deque bases = [false, false, true] playing_field = deque(bases) print(playing_field) #deque([false, false, true])  playing_field.rotate(-1)   print(playing_field) #deque([false, true, false])  #can use list: print(playing_field[0]) #false 

deque collections perfect want do. can shift list , add member first base.

rotate() takes integer, positive or negative, , shifts list many times left or right.

if you, make include home plate, can pop off , score or not. if need deque has popleft() , popright() methods literally take left or right item off list.


Comments

Popular posts from this blog

account - Script error login visual studio DefaultLogin_PCore.js -

xcode - CocoaPod Storyboard error: -