how to display my list with n amount on each line in Python
- by user1786698
im trying to display my list with 7 states on each line here is what i have so far, but it displays as one long string of all the states with quotes around each state. I forgot to mention that this is for my CS class and we havent learned iter yet so we not allowed to use it. the only hint i was given was to to turn STATE_LIST into a string then use '\n' to break it up
state = str(STATE_LIST)
displaystates = Text(Point(WINDOW_WIDTH/2, WINDOW_HEIGHT/2), state.split('\n'))
displaystates.draw(win)
and STATE_LIST looks like this
STATE_VOTES = {
"AL" : 9, # Alabama
"AK" : 3, # Alaska
"AZ" : 11, # Arizona
"AR" : 6, # Arkansas
"CA" : 55, # California
"CO" : 9, # Colorado
"CT" : 7, # Connecticut
"DE" : 3, # Delaware
"DC" : 3, # Washington DC
"FL" : 29, # Florida
"GA" : 16, # Georgia
"HI" : 4, # Hawaii
"ID" : 4, # Idaho
"IL" : 20, # Illinois
"IN" : 11, # Indiana
"IA" : 6, # Iowa
"KS" : 6, # Kansas
"KY" : 8, # Kentucky
"LA" : 8, # Louisiana
"ME" : 4, # Maine
"MD" : 10, # Maryland
"MA" : 11, # Massachusetts
"MI" : 16, # Michigan
"MN" : 10, # Minnesota
"MS" : 6, # Mississippi
"MO" : 10, # Missouri
"MT" : 3, # Montana
"NE" : 5, # Nebraska
"NV" : 6, # Nevada
"NH" : 4, # New Hampshire
"NJ" : 14, # New Jersey
"NM" : 5, # New Mexico
"NY" : 29, # New York
"NC" : 15, # North Carolina
"ND" : 3, # North Dakota
"OH" : 18, # Ohio
"OK" : 7, # Oklahoma
"OR" : 7, # Oregon
"PA" : 20, # Pennsylvania
"RI" : 4, # Rhode Island
"SC" : 9, # South Carolina
"SD" : 3, # South Dakota
"TN" : 11, # Tennessee
"TX" : 38, # Texas
"UT" : 6, # Utah
"VT" : 3, # Vermont
"VA" : 13, # Virginia
"WA" : 12, # Washington
"WV" : 5, # West Virginia
"WI" : 10, # Wisconsin
"WY" : 3 # Wyoming
}
STATE_LIST = sorted(list(STATE_VOTES.keys()))
I am trying to get it to look somewhat like this