Related
This is the data as a list:
states = ['Alabama (AL)', 'Alaska (AK)', 'Arizona (AZ)', 'Arkansas (AR)', 'California (CA)', 'Colorado (CO)', 'Connecticut (CT)', 'Delaware (DE)', 'District of Columbia (DC)', 'Florida (FL)', 'Georgia (GA)', 'Hawaii (HI)', 'Idaho (ID)', 'Illinois (IL)', 'Indiana (IN)', 'Iowa (IA)', 'Kansas (KS)', 'Kentucky (KY)', 'Louisiana (LA)', 'Maine (ME)', 'Maryland (MD)', 'Massachusetts (MA)', 'Michigan (MI)', 'Minnesota (MN)', 'Mississippi (MS)', 'Missouri (MO)', 'Montana (MT)', 'Nebraska (NE)', 'Nevada (NV)', 'New Hampshire (NH)', 'New Jersey (NJ)', 'New Mexico (NM)', 'New York (NY)', 'North Carolina (NC)', 'North Dakota (ND)', 'Ohio (OH)', 'Oklahoma (OK)', 'Oregon (OR)', 'Pennsylvania (PA)', 'Rhode Island (RI)', 'South Carolina (SC)', 'South Dakota (SD)', 'Tennessee (TN)', 'Texas (TX)', 'Utah (UT)', 'Vermont (VT)', 'Virginia (VA)', 'Washington (WA)', 'West Virginia (WV)', 'Wisconsin (WI)', 'Wyoming (WY)']
I want to extract all the codes in parentheses.
This code returned None:
re.search('[(A-Z)]')
How can I do this?
Since you're using a list, you probably don't need a regex. If you're guaranteed that's the format, something like this should do it:
abbreviations = [state[-3:-1] for state in states]
That code uses a List Comprehension to make a new list from your old list. For each item in the states list, we're using negative indexes (which start at the back of the string) and the slice operator to pull out the abbreviations since they're always the 2nd to last and 3rd to last characters in the strings.
Sample usage:
>>> states = ['Alabama (AL)', 'Alaska (AK)', 'Arizona (AZ)', 'Arkansas (AR)', 'California (CA)']
>>> [state[-3:-1] for state in states]
['AL', 'AK', 'AZ', 'AR', 'CA']
import re
regex = r"(?<=\()[A-Z]+(?=\))"
print(re.findall(regex, "".join(states)))
Output:
['AL', 'AK', 'AZ', 'AR', 'CA', 'CO', 'CT', 'DE', 'DC', 'FL', 'GA', 'HI', 'ID', 'IL', 'IN', 'IA', 'KS', 'KY', 'LA', 'ME', 'MD', 'MA', 'MI', 'MN', 'MS', 'MO', 'MT', 'NE', 'NV', 'NH', 'NJ', 'NM', 'NY', 'NC', 'ND', 'OH', 'OK', 'OR', 'PA', 'RI', 'SC', 'SD', 'TN', 'TX', 'UT', 'VT', 'VA', 'WA', 'WV', 'WI', 'WY']
I am trying to format a list of cities into json to put it on a firebase database.
I am really new to coding and very lost. Working in python but just trying to get this text formatted.
My list of cities
cities = ['Abu Dhabi', 'Albuquerque', 'Amsterdam', 'Anchorage', 'Antalya', 'Aspen', 'Athens', 'Atlanta', 'Austin', 'Bali', 'Baltimore', 'Bangalore', 'Bangkok', 'Barcelona', 'Beijing', 'Berlin', 'Berlin', 'Bogota', 'Bora Bora', 'Boston', 'Brisbane', 'Brussels', 'Buffalo', 'Burbank', 'Cairo', 'Cancun', 'Cape Town', 'Changcha', 'Charlotte', 'Chengdu', 'Chicago', 'Chongqing', 'Cincinnati']
I need to format them like this
},
"Seattle" : {
"city_name" : "Seattle"
},
"Houston" : {
"city_name" : "Houston"
}
What is the best way to go about doing this?
You can use a simple dict comprehension:
cities = ['Chicago', 'Charlotte', 'Barcelona']
print({city: {'city_name': city} for city in cities})
Which prints:
{'Chicago': {'city_name': 'Chicago'}, 'Charlotte': {'city_name': 'Charlotte'}, 'Barcelona': {'city_name': 'Barcelona'}}
I'm attempting to use the GTab package to query Google Search trends data for every state in the US, but am having some trouble getting my loop to work.
For one state it's easy enough to do this, and new_query produces a dataframe.
t = gtab.GTAB()
t.set_options(pytrends_config={"geo": "US-NY", "timeframe": "2020-09-01 2020-10-01"})
query = t.new_query("weather")
To loop through I'm trying to use a dict to assign geo dynamically. However, I can't figure out how to do the same for the df name (query).
state_abbrevs = {
'Alabama': 'AL',
'Alaska': 'AK',
'Arizona': 'AZ',
'Arkansas': 'AR',
'California': 'CA',
'Colorado': 'CO',
'Connecticut': 'CT',
'Delaware': 'DE',
'District of Columbia': 'DC',
'Florida': 'FL',
'Georgia': 'GA',
'Guam': 'GU',
'Hawaii': 'HI',
'Idaho': 'ID',
'Illinois': 'IL',
'Indiana': 'IN',
'Iowa': 'IA',
'Kansas': 'KS',
'Kentucky': 'KY',
'Louisiana': 'LA',
'Maine': 'ME',
'Maryland': 'MD',
'Massachusetts': 'MA',
'Michigan': 'MI',
'Minnesota': 'MN',
'Mississippi': 'MS',
'Missouri': 'MO',
'Montana': 'MT',
'Nebraska': 'NE',
'Nevada': 'NV',
'New Hampshire': 'NH',
'New Jersey': 'NJ',
'New Mexico': 'NM',
'New York': 'NY',
'North Carolina': 'NC',
'North Dakota': 'ND',
'Northern Mariana Islands':'MP',
'Ohio': 'OH',
'Oklahoma': 'OK',
'Oregon': 'OR',
'Pennsylvania': 'PA',
'Puerto Rico': 'PR',
'Rhode Island': 'RI',
'South Carolina': 'SC',
'South Dakota': 'SD',
'Tennessee': 'TN',
'Texas': 'TX',
'Utah': 'UT',
'Vermont': 'VT',
'Virgin Islands': 'VI',
'Virginia': 'VA',
'Washington': 'WA',
'Washington DC' : 'DC',
'West Virginia': 'WV',
'Wisconsin': 'WI',
'Wyoming': 'WY'
}
for v in state_abbrevs.values():
t = gtab.GTAB()
t.set_options(pytrends_config={"geo": f"US-{v}", "timeframe": "2020-09-01 2020-10-01"})
query = t.new_query("weather")
I've tried using an f string but that produces SyntaxError: can't assign to literal.
I used two answers from here. I think your best option is just storing the DataFrames in a dictionary but this should work to create your query_* variables.
query_dict = {}
for n, v in enumerate(state_abbrevs.values()):
t = gtab.GTAB()
t.set_options(pytrends_config={"geo": f"US-{v}", "timeframe": "2020-09-01 2020-10-01"})
query = t.new_query("weather")
key = "query_" + str(n)
query_dict[key] = query
for k in query_dict.keys():
exec("%s = query_dict['%s']" % (k,k))
I have been following an example program from a tutorial book, the program is to take a dictionary with all 50 US states in and their capitals and then to create a random set of multiple choice A-D questions, these questions are then to be randomised and 3 different quizzes printed out into 3 different files. The answers for all the questions for each quiz are then to be printed out into an answers file to go with each questions file.
As a test I'm only doing it with a range of 5 for now. When I run the program the program works as intended except only 25 question/answer combos are created for each test, rather than 50.
I have checked it a few times and can't figure out why this is. Any input would be greatly appreciated, thanks.
# randomQuizGenerator.py - Creates quizzes with questions and answers in
# random order, along with the answer key.
import random
capitals = {'Alabama': 'Montgomery', 'Alaska': 'Juneau', 'Arizona': 'Phoenix',
'Arkansas': 'Little Rock', 'California': 'Sacramento', 'Colorado': 'Denver',
'Connecticut': 'Hartford', 'Delaware': 'Dover', 'Florida': 'Tallahassee',
'Georgia': 'Atlanta', 'Hawaii': 'Honolulu', 'Idaho': 'Boise', 'Illinois':
'Springfield', 'Indiana': 'Indianapolis', 'Iowa': 'Des Moines', 'Kansas':
'Topeka', 'Kentucky': 'Frankfort', 'Louisiana': 'Baton Rouge', 'Maine':
'Augusta', 'Maryland': 'Annapolis', 'Massachusetts': 'Boston', 'Michigan':
'Lansing', 'Minnesota': 'Saint Paul', 'Mississippi': 'Jackson', 'Missouri':
'Jefferson City', 'Montana': 'Helena', 'Nebraska': 'Lincoln', 'Nevada':
'Carson City', 'New Hampshire': 'Concord', 'New Jersey': 'Trenton',
'New Mexico': 'Santa Fe', 'New York': 'Albany', 'North Carolina': 'Raleigh',
'North Dakota': 'Bismarck', 'Ohio': 'Columbus', 'Oklahoma': 'Oklahoma City',
'Oregon': 'Salem', 'Pennsylvania': 'Harrisburg', 'Rhode Island': 'Providence',
'South Carolina': 'Columbia', 'South Dakota': 'Pierre', 'Tennessee':
'Nashville', 'Texas': 'Austin', 'Utah': 'Salt Lake City', 'Vermont':
'Montpelier', 'Virginia': 'Richmond', 'Washington': 'Olympia',
'West Virginia': 'Charleston', 'Wisconsin': 'Madison', 'Wyoming': 'Cheyenne'}
# Generate 5 quiz files.
for quizNum in range(5):
# Create the quiz and answer key files.
quizFile = open('capitalsquiz%s.txt' % (quizNum+1), 'w')
answerFile = open('capitalsquiz_answers%s.txt' % (quizNum+1), 'w')
# Write out the header for the quiz.
quizFile.write('Capitals Quiz #%s' % (quizNum+1) + '\nName:\nDate:\n\n')
quizFile.write('What is the capital of:\n')
answerFile.write('Capitals Quiz %s' % (quizNum+1) + '\n\n')
# Shuffle the order of the states.
states = list(capitals.keys())
random.shuffle(states)
# Loop through all 50 states, making a question for each.
# set question number = 0
q_num = 0
for st in states:
# question number increase
q_num += 1
random.shuffle(states)
# unused needed for choosing 3 incorrect options
unusedStates = states
# write question number and state name (QUESTION)
quizFile.write('Q%s: ' % q_num + st + '?\n')
# create answer options list and fill with 1 correct answer + 3 incorrect ones
answerOptions = [None] * 3
answerOptions.append(capitals[st])
# remove correct answer to avoid duplication
unusedStates.remove(st)
for Opt in range(0, 3):
curr_ans = unusedStates[Opt]
answerOptions[Opt] = capitals[curr_ans]
# randomise answer list
random.shuffle(answerOptions)
# write answers
for i in range(0, 4):
quizFile.write(answerOptions[i]+' ')
quizFile.write('\n')
# write correct answer in answer file
answerFile.write(capitals[st]+'\n')
quizFile.close()
answerFile.close()
The reason it's happening is because you are modifying your collection while iterating over it:
states = [1,2,3,4,5,6,7,8,9,10]
for st in states:
print(st)
states.remove(st)
This snippet will print out:
1
3
5
7
9
What you have tried is:
unusedStates = states
unusedStates.remove(st)
but this will not copy the list. It will just create another name for the same list.
Here is a slightly changed version, but I am by no means a "Python pro".
import random
capitals = {'Alabama': 'Montgomery', 'Alaska': 'Juneau', 'Arizona': 'Phoenix',
'Arkansas': 'Little Rock', 'California': 'Sacramento', 'Colorado': 'Denver',
'Connecticut': 'Hartford'}
states = list(capitals.keys())
random.shuffle(states)
# Loop through all 50 states, making a question for each.
for idx, state in enumerate(states):
# use this for 1-based humans
q_num = idx + 1
# the 49 other states
other_states = states[:idx] + states[idx+1:]
# pick 3 states (guaranteed to be unique)
answer_states = random.sample(other_states, 3)
# add the correct one
answer_states.append(state)
# convert states to capitals
answer_options = [capitals[st] for st in answer_states]
# randomise answer list
random.shuffle(answer_options)
print('Question %s about %s' % (q_num, state))
print('Options', answer_options)
print('Correct Answer', capitals[state])
print() #empty line
Note the use of random.sample to pick 3 unique options, using enumerate to iterate over the list with an index variable.
Also note the creation of a 49-element list using "slicing".
#hlfrmn found the codeculprit - I would like to point out another thing - use the
with open("filename.txt","w") as f:
f.write("something")
approach that autocloses your file even if you encounter exceptions and structure it using functions that perform certain tasks.
The data definition:
capitals = {'Alabama': 'Montgomery', 'Alaska': 'Juneau', 'Arizona': 'Phoenix',
'Arkansas': 'Little Rock', 'California': 'Sacramento', 'Colorado': 'Denver',
'Connecticut': 'Hartford', 'Delaware': 'Dover', 'Florida': 'Tallahassee',
'Georgia': 'Atlanta', 'Hawaii': 'Honolulu', 'Idaho': 'Boise', 'Illinois':
'Springfield', 'Indiana': 'Indianapolis', 'Iowa': 'Des Moines', 'Kansas':
'Topeka', 'Kentucky': 'Frankfort', 'Louisiana': 'Baton Rouge', 'Maine':
'Augusta', 'Maryland': 'Annapolis', 'Massachusetts': 'Boston', 'Michigan':
'Lansing', 'Minnesota': 'Saint Paul', 'Mississippi': 'Jackson', 'Missouri':
'Jefferson City', 'Montana': 'Helena', 'Nebraska': 'Lincoln', 'Nevada':
'Carson City', 'New Hampshire': 'Concord', 'New Jersey': 'Trenton',
'New Mexico': 'Santa Fe', 'New York': 'Albany', 'North Carolina': 'Raleigh',
'North Dakota': 'Bismarck', 'Ohio': 'Columbus', 'Oklahoma': 'Oklahoma City',
'Oregon': 'Salem', 'Pennsylvania': 'Harrisburg', 'Rhode Island': 'Providence',
'South Carolina': 'Columbia', 'South Dakota': 'Pierre', 'Tennessee':
'Nashville', 'Texas': 'Austin', 'Utah': 'Salt Lake City', 'Vermont':
'Montpelier', 'Virginia': 'Richmond', 'Washington': 'Olympia',
'West Virginia': 'Charleston', 'Wisconsin': 'Madison', 'Wyoming': 'Cheyenne'}
and code:
import random
def generateAllQuestions(caps):
"""Generates all questions including 3 wrong answers. Returns a list of
[tuple(state,correct) and list of 3 wrong answers]."""
q = []
for state in capitals:
# get 4 other answers
# remove the correct one if it is inside the random sample
# use only 3 of them
others = [ val for key,val in random.sample(capitals.items(),k=4) if key != state][0:3]
# compile [tuple: (item,correct_answer),[other_answers]]
q.append([(state,capitals[state])] + [others])
return q
def partitionIntoNParts(n,data):
"""Takes the data and partiniones it into n random equally long (if possible)
sublists"""
ld = len(data)
size_part = ld // n
idx = 0
random.shuffle(data)
while idx < ld:
yield data[idx:idx + size_part]
idx += size_part
def writeHeader(f,a,n):
"""Write the header for Q and A file"""
a.write(f"Capitals Quiz #{n+1}\n\n")
f.write(f"Capitals Quiz #{n+1}\nName:\nDate:\n\nWhat is the capital of:\n")
def writeQandA(f,a,q_num,q):
"""Write a single questions into Q-file and a single answer into A-file"""
state,correct = q[0] # the tuple
others = q[1] # the others
a.write(f"{q_num+1:>3}.) {state:<14} : {correct}\n")
f.write(f"{q_num+1:>3}.) {state:<14} : ")
solutions = others + [correct]
random.shuffle(solutions) # use sort() to always get alphabetical order
for town in solutions:
f.write(f"[ ] {town:<14} ")
f.write("\n\n")
# how many files to use?
filecount = 5
qs = generateAllQuestions(capitals)
parts = partitionIntoNParts(filecount,qs)
# write files based on partioning
for idx,content in enumerate(parts):
with open(f"capitalsquiz{idx+1}.txt","w") as quiz_file,\
open(f"capitalsquiz{idx+1}_answers.txt","w") as answ_file:
writeHeader(quiz_file,answ_file,idx)
# write Q and A into file
for q_num,q in enumerate(content):
writeQandA(quiz_file,answ_file,q_num,q)
# check one files content:
print(open("capitalsquiz2.txt").read())
print(open("capitalsquiz2_answers.txt").read())
Content of capitalsquiz2.txt:
Capitals Quiz #2
Name:
Date:
What is the capital of:
1.) Oklahoma : [ ] Oklahoma City [ ] Phoenix [ ] Juneau [ ] Olympia
2.) Virginia : [ ] Austin [ ] Pierre [ ] Saint Paul [ ] Richmond
3.) North Carolina : [ ] Raleigh [ ] Tallahassee [ ] Dover [ ] Harrisburg
4.) Montana : [ ] Helena [ ] Raleigh [ ] Hartford [ ] Madison
5.) Alaska : [ ] Nashville [ ] Albany [ ] Juneau [ ] Lansing
6.) Kentucky : [ ] Charleston [ ] Cheyenne [ ] Frankfort [ ] Oklahoma City
7.) Florida : [ ] Trenton [ ] Pierre [ ] Tallahassee [ ] Honolulu
8.) Rhode Island : [ ] Providence [ ] Madison [ ] Santa Fe [ ] Trenton
9.) Arkansas : [ ] Boston [ ] Little Rock [ ] Harrisburg [ ] Denver
10.) Wisconsin : [ ] Montgomery [ ] Pierre [ ] Madison [ ] Richmond
Content of capitalsquiz2_answers.txt`:
Capitals Quiz #1
1.) Oklahoma : Oklahoma City
2.) Virginia : Richmond
3.) North Carolina : Raleigh
4.) Montana : Helena
5.) Alaska : Juneau
6.) Kentucky : Frankfort
7.) Florida : Tallahassee
8.) Rhode Island : Providence
9.) Arkansas : Little Rock
10.) Wisconsin : Madison
Hehe... I also had some fun restructuring your program. Maybe you can learn a thing or two from this.
import random
capitals = {'Alabama': 'Montgomery', 'Alaska': 'Juneau', 'Arizona': 'Phoenix',
'Arkansas': 'Little Rock', 'California': 'Sacramento', 'Colorado': 'Denver',
'Connecticut': 'Hartford', 'Delaware': 'Dover', 'Florida': 'Tallahassee',
'Georgia': 'Atlanta', 'Hawaii': 'Honolulu', 'Idaho': 'Boise', 'Illinois':
'Springfield', 'Indiana': 'Indianapolis', 'Iowa': 'Des Moines', 'Kansas':
'Topeka', 'Kentucky': 'Frankfort', 'Louisiana': 'Baton Rouge', 'Maine':
'Augusta', 'Maryland': 'Annapolis', 'Massachusetts': 'Boston', 'Michigan':
'Lansing', 'Minnesota': 'Saint Paul', 'Mississippi': 'Jackson', 'Missouri':
'Jefferson City', 'Montana': 'Helena', 'Nebraska': 'Lincoln', 'Nevada':
'Carson City', 'New Hampshire': 'Concord', 'New Jersey': 'Trenton',
'New Mexico': 'Santa Fe', 'New York': 'Albany', 'North Carolina': 'Raleigh',
'North Dakota': 'Bismarck', 'Ohio': 'Columbus', 'Oklahoma': 'Oklahoma City',
'Oregon': 'Salem', 'Pennsylvania': 'Harrisburg', 'Rhode Island': 'Providence',
'South Carolina': 'Columbia', 'South Dakota': 'Pierre', 'Tennessee':
'Nashville', 'Texas': 'Austin', 'Utah': 'Salt Lake City', 'Vermont':
'Montpelier', 'Virginia': 'Richmond', 'Washington': 'Olympia',
'West Virginia': 'Charleston', 'Wisconsin': 'Madison', 'Wyoming': 'Cheyenne'}
quiz_answer_template = '''\
Capitals Quiz #{}
{}
'''
quiz_file_template = '''\
Capitals Quiz #{}
Name:
Date:
What is the capital of?
{}
'''
question_template = '''\
Q{} {}?
{}
'''
def create_answer_file(path, question_id, answers):
with open(path, 'w') as f:
s = quiz_answer_template.format(question_id, answers)
f.write(s)
def create_quiz_file(path, question_id, question_and_options):
with open(path, 'w') as f:
s = quiz_file_template.format(question_id, question_and_options)
f.write(s)
def get_quiz(dictionary, n):
"""Based on a dictionary with key and values will return
1) Questions with 4 options tab-separated as a string
2) Correct answers as a string
"""
output = []
states = list(dictionary.keys())
random.shuffle(states)
correct_answers = [dictionary.get(i) for i in states]
for ind, st in enumerate(states[:n], 1):
d = dictionary.copy()
correct_answer = d.pop(st)
incorrect_answers = list(d.values())
random.shuffle(incorrect_answers)
options = [correct_answer] + incorrect_answers[:3]
random.shuffle(options)
output.append(question_template.format(ind, st, '\t'.join(options)))
return '\n'.join(output), '\n'.join(correct_answers)
for quizNum in range(1, 6):
questions_and_options, answers = get_quiz(capitals, n=50)
create_quiz_file(f'capitalsquiz{quizNum}.txt', quizNum, questions_and_options)
create_answer_file(f'capitalsquiz_answers{quizNum}.txt', quizNum, answers)
Here is the code:
import requests
import bs4
response = requests.get('http://discoverygc.com/forums/serverinterface.php?action=players_online') #Loads page
soup = bs4.BeautifulSoup(response.text)
table = soup.find("div", {"id": "forum"})
rowsNo = (str(table).count('<tr>') - 2) #Number of players online. Minus 2 to remove leading title and column description rows
players = systems = [] #Define lists
for i in range(3, (rowsNo + 3)):
rows = table.findAll('tr')[i]
cols = rows.findAll('td')
player = cols[0].get_text()
system = cols[1].get_text()
players.append(player)
systems.append(system)
print(players)
print(systems)
If I remove either players.append(player) or systems.append(system) the code works fine and outputs the correct list:
['-Vasqez-', '[-=XTF=-]Neon.Bunny-[R]', "[SV]-Valley'", '<-JohnyWalker->', '~VP)Bad.Tibira', 'Alkanius', 'Apex91', 'Araroba', 'Baldor', 'Benediction', 'Black_Bird', 'Boost', 'Caelius.Moya[X]', 'Core|APM-Maverick', 'Daftwagen', 'Dee.Leers', 'Emiko:Hayashi', 'Gamma-6', 'Gauri', 'Gigi.7', 'GMG|GTS-Komahashi-Maru', 'Grawmod', 'GrazySlon', 'Hunor', 'Jakob-Schleiter', 'Joyita', 'Judge_BigJo', 'JulyJalwa', 'Kruger|KMS-Lankow', 'Luxor', 'monitor91', 'Morgulis', 'Nuggets', 'OSI-Mendes', 'Ronny.Rochester', 'Samura|-Arata', 'Samura|-Ichikawa', 'Shpritzen', 'Stardrifter', 'The_Altair', 'The.Liner.of.Dreams', 'Tony.Sosa', 'Wilde.RNC-Nestor']
or:
['Omega-11', 'Omega-49', 'Pennsylvania', 'Magellan', 'Omicron Gamma', 'Kyushu', 'Pennsylvania', 'Kyushu', 'Omega-5', 'Manchester', 'Cassini', 'Newcastle', 'Connecticut', 'Omega-47', 'Stuttgart', 'Stuttgart', 'Munich', 'New York', 'Hudson', 'Sigma-13', 'Languedoc', 'Colorado', 'Virginia', 'Stuttgart', 'New London', 'Magellan', 'New York', 'New Tokyo', 'Manchester', 'New York', 'Pennsylvania', 'Omega-3', 'Omega-49', 'New Berlin', 'California', 'Nagano', 'New Berlin', 'Okinawa', 'Magellan', 'Texas', 'Ontario', 'New Berlin', 'Stuttgart']
However if I put both lines in it mixes the two together for both lists:
['-Vasqez-', 'Omega-11', "[SV]-Valley'", 'Omega-49', '<-JohnyWalker->', 'Pennsylvania', '=Z=Exositas', 'Magellan', '~VP)Death.Incarnator', 'Omicron Gamma', 'Alkanius', 'Shikoku', 'Apex91', 'Pennsylvania', 'Baldor', 'Kyushu', 'Benediction', 'Omega-5', 'Black_Bird', 'Manchester', 'Boost', 'Cassini', 'Caelius.Moya[X]', 'Connecticut', 'Core|APM-Maverick', 'Omega-47', 'Daftwagen', 'Stuttgart', 'Darf.Acour', 'Texas', 'Dee.Leers', 'New Berlin', 'Emiko:Hayashi', 'Munich', 'Gamma-6', 'New York', 'Gauri', 'Hudson', 'Gigi.7', 'Orkney', 'GMG|GTS-Komahashi-Maru', 'Colorado', 'Grawmod', 'Virginia', 'GrazySlon', 'Stuttgart', 'Hunor', 'Manchester', 'Jakob-Schleiter', 'New Berlin', 'Joyita', 'Magellan', 'Judge_BigJo', 'New York', 'Kruger|KMS-Lankow', 'New Tokyo', 'Luxor', 'Manchester', 'monitor91', 'New York', 'Morgulis', 'Pennsylvania', 'Nuggets', 'Omega-3', 'OSI-Mendes', 'Omega-49', 'Ronny.Rochester', 'California', 'Samura|-Arata', 'Nagano', 'Samura|-Ichikawa', 'New Berlin', 'Stardrifter', 'Okinawa', 'The_Altair', 'Magellan', 'Tony.Sosa', 'Ontario', 'Wilde.RNC-Nestor', 'Omega-7']
Why is this? I cannot see any reason why this should happen.
Don't do this, they will refer to the same list:
players = systems = [] #Define lists
But split them:
players = []
systems = [] #Define lists
Then you will have two separate lists.
Your style is used for creating name aliases of a list (in some cases, it might be useful), not to create two different lists
where you have players = systems = [] change it to separate assignments.
players = []
systems = []
If you want to keep it in one line:
players, systems = [], []