Python: Generating a new name based on value in multiple dictionary
Relatively new to python, apologies if the question/script is verbose and vague. The script below returns the key and value of the team name searched (Ex: 2, Charlotte Hornets); however, I would also like it to return the league name it's in as well. Such as 'nfl', 'nba', 'mlb'; based on the dictionary it's found in (Ex: 2, Charlotte Hornets, nba). Been working on this for a while, but can't find a dynamic solution. Thanks for the help in advance!
NFL_Teams = {1: "Arizona Cardinals", 2: "Atlanta Falcons", 3: "Baltimore Ravens"}
NBA_Teams = {1:'Washington Wizards', 2:'Charlotte Hornets', 3: 'Atlanta Hawks'}
MLB_Teams = {1: 'Los Angeles Dogers', 2: 'Cincinnati Reds', 3: 'Toronto Blue Jays'}
def Standings(reply):
def dictionary_search(name, dictionary):
for key, value in dictionary.items():
if value == name:
return True # Boolean to show if team name is in merged dictionaries.
if key == name:
pass # Used as a throw-away variable
for single_dictionary in (NFL_Teams, NBA_Teams, MLB_Teams):
if dictionary_search(reply, single_dictionary):
for key, value in single_dictionary.items():
if reply == value:
print(key, value)
break
else:
print('Please Try Again')
Standings('Charlotte Hornets')
python python-3.x loops dictionary for-loop
add a comment |
Relatively new to python, apologies if the question/script is verbose and vague. The script below returns the key and value of the team name searched (Ex: 2, Charlotte Hornets); however, I would also like it to return the league name it's in as well. Such as 'nfl', 'nba', 'mlb'; based on the dictionary it's found in (Ex: 2, Charlotte Hornets, nba). Been working on this for a while, but can't find a dynamic solution. Thanks for the help in advance!
NFL_Teams = {1: "Arizona Cardinals", 2: "Atlanta Falcons", 3: "Baltimore Ravens"}
NBA_Teams = {1:'Washington Wizards', 2:'Charlotte Hornets', 3: 'Atlanta Hawks'}
MLB_Teams = {1: 'Los Angeles Dogers', 2: 'Cincinnati Reds', 3: 'Toronto Blue Jays'}
def Standings(reply):
def dictionary_search(name, dictionary):
for key, value in dictionary.items():
if value == name:
return True # Boolean to show if team name is in merged dictionaries.
if key == name:
pass # Used as a throw-away variable
for single_dictionary in (NFL_Teams, NBA_Teams, MLB_Teams):
if dictionary_search(reply, single_dictionary):
for key, value in single_dictionary.items():
if reply == value:
print(key, value)
break
else:
print('Please Try Again')
Standings('Charlotte Hornets')
python python-3.x loops dictionary for-loop
1
You basically want to get the name of the variable that holds the data. You can't do this (well, not without some weird trickery), but you can just make a dictionary of dictionaries, where the keys would be the names of the teams, and the values - your original dictionaries (which can be simply lists, BTW).
– ForceBru
Dec 30 '18 at 20:22
add a comment |
Relatively new to python, apologies if the question/script is verbose and vague. The script below returns the key and value of the team name searched (Ex: 2, Charlotte Hornets); however, I would also like it to return the league name it's in as well. Such as 'nfl', 'nba', 'mlb'; based on the dictionary it's found in (Ex: 2, Charlotte Hornets, nba). Been working on this for a while, but can't find a dynamic solution. Thanks for the help in advance!
NFL_Teams = {1: "Arizona Cardinals", 2: "Atlanta Falcons", 3: "Baltimore Ravens"}
NBA_Teams = {1:'Washington Wizards', 2:'Charlotte Hornets', 3: 'Atlanta Hawks'}
MLB_Teams = {1: 'Los Angeles Dogers', 2: 'Cincinnati Reds', 3: 'Toronto Blue Jays'}
def Standings(reply):
def dictionary_search(name, dictionary):
for key, value in dictionary.items():
if value == name:
return True # Boolean to show if team name is in merged dictionaries.
if key == name:
pass # Used as a throw-away variable
for single_dictionary in (NFL_Teams, NBA_Teams, MLB_Teams):
if dictionary_search(reply, single_dictionary):
for key, value in single_dictionary.items():
if reply == value:
print(key, value)
break
else:
print('Please Try Again')
Standings('Charlotte Hornets')
python python-3.x loops dictionary for-loop
Relatively new to python, apologies if the question/script is verbose and vague. The script below returns the key and value of the team name searched (Ex: 2, Charlotte Hornets); however, I would also like it to return the league name it's in as well. Such as 'nfl', 'nba', 'mlb'; based on the dictionary it's found in (Ex: 2, Charlotte Hornets, nba). Been working on this for a while, but can't find a dynamic solution. Thanks for the help in advance!
NFL_Teams = {1: "Arizona Cardinals", 2: "Atlanta Falcons", 3: "Baltimore Ravens"}
NBA_Teams = {1:'Washington Wizards', 2:'Charlotte Hornets', 3: 'Atlanta Hawks'}
MLB_Teams = {1: 'Los Angeles Dogers', 2: 'Cincinnati Reds', 3: 'Toronto Blue Jays'}
def Standings(reply):
def dictionary_search(name, dictionary):
for key, value in dictionary.items():
if value == name:
return True # Boolean to show if team name is in merged dictionaries.
if key == name:
pass # Used as a throw-away variable
for single_dictionary in (NFL_Teams, NBA_Teams, MLB_Teams):
if dictionary_search(reply, single_dictionary):
for key, value in single_dictionary.items():
if reply == value:
print(key, value)
break
else:
print('Please Try Again')
Standings('Charlotte Hornets')
python python-3.x loops dictionary for-loop
python python-3.x loops dictionary for-loop
asked Dec 30 '18 at 20:18
DG.FinanceDG.Finance
206
206
1
You basically want to get the name of the variable that holds the data. You can't do this (well, not without some weird trickery), but you can just make a dictionary of dictionaries, where the keys would be the names of the teams, and the values - your original dictionaries (which can be simply lists, BTW).
– ForceBru
Dec 30 '18 at 20:22
add a comment |
1
You basically want to get the name of the variable that holds the data. You can't do this (well, not without some weird trickery), but you can just make a dictionary of dictionaries, where the keys would be the names of the teams, and the values - your original dictionaries (which can be simply lists, BTW).
– ForceBru
Dec 30 '18 at 20:22
1
1
You basically want to get the name of the variable that holds the data. You can't do this (well, not without some weird trickery), but you can just make a dictionary of dictionaries, where the keys would be the names of the teams, and the values - your original dictionaries (which can be simply lists, BTW).
– ForceBru
Dec 30 '18 at 20:22
You basically want to get the name of the variable that holds the data. You can't do this (well, not without some weird trickery), but you can just make a dictionary of dictionaries, where the keys would be the names of the teams, and the values - your original dictionaries (which can be simply lists, BTW).
– ForceBru
Dec 30 '18 at 20:22
add a comment |
2 Answers
2
active
oldest
votes
Once you assign the dict to another var called 'single_dictionary', you actually lose the name.. So i tried to map between the league name to the original dict of teams.
Running on:
teams = {'NFL': {1: "Arizona Cardinals", 2: "Atlanta Falcons", 3: "Baltimore Ravens"},
'NBA': {1:'Washington Wizards', 2:'Charlotte Hornets', 3: 'Atlanta Hawks'},
'MLB': {1: 'Los Angeles Dogers', 2: 'Cincinnati Reds', 3: 'Toronto Blue Jays'}}
# NFL_Teams = {1: "Arizona Cardinals", 2: "Atlanta Falcons", 3: "Baltimore Ravens"}
# NBA_Teams = {1:'Washington Wizards', 2:'Charlotte Hornets', 3: 'Atlanta Hawks'}
# MLB_Teams = {1: 'Los Angeles Dogers', 2: 'Cincinnati Reds', 3: 'Toronto Blue Jays'}
def standings(reply):
for league, single_dictionary in teams.items():
if reply in single_dictionary.values():
for key, value in single_dictionary.items():
if reply == value:
print(key, value)
print(league)
break
else:
print('Please Try Again')
standings('Charlotte Hornets')
Will print:
2 Charlotte Hornets
NBA
Can't thank you enough! Struggled to think that through for a solid hour.
– DG.Finance
Dec 30 '18 at 20:36
add a comment |
Are the numbers used as keys important?
Would it make sense to have read them into the dictionaries the other way around? - then you can use a try except KeyError statement. This might be preferable for very large dictionaries (though this won't be the case here for teams in a league). It also might be a more object orientated way of thinking: the team name is the object identifier, whilst (I presume the numbers are current league positions?) league position is a property (and a changeable one at that). So for example (adapting Aaron_ab's answer)
teams = {'NFL': {"Arizona Cardinals":1, "Atlanta Falcons":2, "Baltimore Ravens":3},
'NBA': {'Washington Wizards':1, 'Charlotte Hornets':2, 'Atlanta Hawks':3},
'MLB': {'Los Angeles Dogers':1, 'Cincinnati Reds':2, 'Toronto Blue Jays':3}}
def standings(team):
for league, teams_dict in teams.items():
try:
teams_dict[team]
print(teams_dict[team], team)
print(league)
break
except KeyError:
continue
Alternatively, drop the numbers and have a dictionary of lists (where the order of the list is the current league order):
import numpy as np
teams = {'NFL': ["Arizona Cardinals", "Atlanta Falcons", "Baltimore Ravens"],
'NBA': ['Washington Wizards', 'Charlotte Hornets', 'Atlanta Hawks'],
'MLB': ['Los Angeles Dogers', 'Cincinnati Reds', 'Toronto Blue Jays']}
def standings(team):
for league, teams_list in teams.items():
if team in teams_list:
print(team, np.where(np.array(teams_list)==team)[0])
print(league)
Raising and catching exceptions costs much more computationally wise, try to avoid as much as possible
– Aaron_ab
Dec 31 '18 at 7:12
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53981104%2fpython-generating-a-new-name-based-on-value-in-multiple-dictionary%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
Once you assign the dict to another var called 'single_dictionary', you actually lose the name.. So i tried to map between the league name to the original dict of teams.
Running on:
teams = {'NFL': {1: "Arizona Cardinals", 2: "Atlanta Falcons", 3: "Baltimore Ravens"},
'NBA': {1:'Washington Wizards', 2:'Charlotte Hornets', 3: 'Atlanta Hawks'},
'MLB': {1: 'Los Angeles Dogers', 2: 'Cincinnati Reds', 3: 'Toronto Blue Jays'}}
# NFL_Teams = {1: "Arizona Cardinals", 2: "Atlanta Falcons", 3: "Baltimore Ravens"}
# NBA_Teams = {1:'Washington Wizards', 2:'Charlotte Hornets', 3: 'Atlanta Hawks'}
# MLB_Teams = {1: 'Los Angeles Dogers', 2: 'Cincinnati Reds', 3: 'Toronto Blue Jays'}
def standings(reply):
for league, single_dictionary in teams.items():
if reply in single_dictionary.values():
for key, value in single_dictionary.items():
if reply == value:
print(key, value)
print(league)
break
else:
print('Please Try Again')
standings('Charlotte Hornets')
Will print:
2 Charlotte Hornets
NBA
Can't thank you enough! Struggled to think that through for a solid hour.
– DG.Finance
Dec 30 '18 at 20:36
add a comment |
Once you assign the dict to another var called 'single_dictionary', you actually lose the name.. So i tried to map between the league name to the original dict of teams.
Running on:
teams = {'NFL': {1: "Arizona Cardinals", 2: "Atlanta Falcons", 3: "Baltimore Ravens"},
'NBA': {1:'Washington Wizards', 2:'Charlotte Hornets', 3: 'Atlanta Hawks'},
'MLB': {1: 'Los Angeles Dogers', 2: 'Cincinnati Reds', 3: 'Toronto Blue Jays'}}
# NFL_Teams = {1: "Arizona Cardinals", 2: "Atlanta Falcons", 3: "Baltimore Ravens"}
# NBA_Teams = {1:'Washington Wizards', 2:'Charlotte Hornets', 3: 'Atlanta Hawks'}
# MLB_Teams = {1: 'Los Angeles Dogers', 2: 'Cincinnati Reds', 3: 'Toronto Blue Jays'}
def standings(reply):
for league, single_dictionary in teams.items():
if reply in single_dictionary.values():
for key, value in single_dictionary.items():
if reply == value:
print(key, value)
print(league)
break
else:
print('Please Try Again')
standings('Charlotte Hornets')
Will print:
2 Charlotte Hornets
NBA
Can't thank you enough! Struggled to think that through for a solid hour.
– DG.Finance
Dec 30 '18 at 20:36
add a comment |
Once you assign the dict to another var called 'single_dictionary', you actually lose the name.. So i tried to map between the league name to the original dict of teams.
Running on:
teams = {'NFL': {1: "Arizona Cardinals", 2: "Atlanta Falcons", 3: "Baltimore Ravens"},
'NBA': {1:'Washington Wizards', 2:'Charlotte Hornets', 3: 'Atlanta Hawks'},
'MLB': {1: 'Los Angeles Dogers', 2: 'Cincinnati Reds', 3: 'Toronto Blue Jays'}}
# NFL_Teams = {1: "Arizona Cardinals", 2: "Atlanta Falcons", 3: "Baltimore Ravens"}
# NBA_Teams = {1:'Washington Wizards', 2:'Charlotte Hornets', 3: 'Atlanta Hawks'}
# MLB_Teams = {1: 'Los Angeles Dogers', 2: 'Cincinnati Reds', 3: 'Toronto Blue Jays'}
def standings(reply):
for league, single_dictionary in teams.items():
if reply in single_dictionary.values():
for key, value in single_dictionary.items():
if reply == value:
print(key, value)
print(league)
break
else:
print('Please Try Again')
standings('Charlotte Hornets')
Will print:
2 Charlotte Hornets
NBA
Once you assign the dict to another var called 'single_dictionary', you actually lose the name.. So i tried to map between the league name to the original dict of teams.
Running on:
teams = {'NFL': {1: "Arizona Cardinals", 2: "Atlanta Falcons", 3: "Baltimore Ravens"},
'NBA': {1:'Washington Wizards', 2:'Charlotte Hornets', 3: 'Atlanta Hawks'},
'MLB': {1: 'Los Angeles Dogers', 2: 'Cincinnati Reds', 3: 'Toronto Blue Jays'}}
# NFL_Teams = {1: "Arizona Cardinals", 2: "Atlanta Falcons", 3: "Baltimore Ravens"}
# NBA_Teams = {1:'Washington Wizards', 2:'Charlotte Hornets', 3: 'Atlanta Hawks'}
# MLB_Teams = {1: 'Los Angeles Dogers', 2: 'Cincinnati Reds', 3: 'Toronto Blue Jays'}
def standings(reply):
for league, single_dictionary in teams.items():
if reply in single_dictionary.values():
for key, value in single_dictionary.items():
if reply == value:
print(key, value)
print(league)
break
else:
print('Please Try Again')
standings('Charlotte Hornets')
Will print:
2 Charlotte Hornets
NBA
answered Dec 30 '18 at 20:27
Aaron_abAaron_ab
1,005723
1,005723
Can't thank you enough! Struggled to think that through for a solid hour.
– DG.Finance
Dec 30 '18 at 20:36
add a comment |
Can't thank you enough! Struggled to think that through for a solid hour.
– DG.Finance
Dec 30 '18 at 20:36
Can't thank you enough! Struggled to think that through for a solid hour.
– DG.Finance
Dec 30 '18 at 20:36
Can't thank you enough! Struggled to think that through for a solid hour.
– DG.Finance
Dec 30 '18 at 20:36
add a comment |
Are the numbers used as keys important?
Would it make sense to have read them into the dictionaries the other way around? - then you can use a try except KeyError statement. This might be preferable for very large dictionaries (though this won't be the case here for teams in a league). It also might be a more object orientated way of thinking: the team name is the object identifier, whilst (I presume the numbers are current league positions?) league position is a property (and a changeable one at that). So for example (adapting Aaron_ab's answer)
teams = {'NFL': {"Arizona Cardinals":1, "Atlanta Falcons":2, "Baltimore Ravens":3},
'NBA': {'Washington Wizards':1, 'Charlotte Hornets':2, 'Atlanta Hawks':3},
'MLB': {'Los Angeles Dogers':1, 'Cincinnati Reds':2, 'Toronto Blue Jays':3}}
def standings(team):
for league, teams_dict in teams.items():
try:
teams_dict[team]
print(teams_dict[team], team)
print(league)
break
except KeyError:
continue
Alternatively, drop the numbers and have a dictionary of lists (where the order of the list is the current league order):
import numpy as np
teams = {'NFL': ["Arizona Cardinals", "Atlanta Falcons", "Baltimore Ravens"],
'NBA': ['Washington Wizards', 'Charlotte Hornets', 'Atlanta Hawks'],
'MLB': ['Los Angeles Dogers', 'Cincinnati Reds', 'Toronto Blue Jays']}
def standings(team):
for league, teams_list in teams.items():
if team in teams_list:
print(team, np.where(np.array(teams_list)==team)[0])
print(league)
Raising and catching exceptions costs much more computationally wise, try to avoid as much as possible
– Aaron_ab
Dec 31 '18 at 7:12
add a comment |
Are the numbers used as keys important?
Would it make sense to have read them into the dictionaries the other way around? - then you can use a try except KeyError statement. This might be preferable for very large dictionaries (though this won't be the case here for teams in a league). It also might be a more object orientated way of thinking: the team name is the object identifier, whilst (I presume the numbers are current league positions?) league position is a property (and a changeable one at that). So for example (adapting Aaron_ab's answer)
teams = {'NFL': {"Arizona Cardinals":1, "Atlanta Falcons":2, "Baltimore Ravens":3},
'NBA': {'Washington Wizards':1, 'Charlotte Hornets':2, 'Atlanta Hawks':3},
'MLB': {'Los Angeles Dogers':1, 'Cincinnati Reds':2, 'Toronto Blue Jays':3}}
def standings(team):
for league, teams_dict in teams.items():
try:
teams_dict[team]
print(teams_dict[team], team)
print(league)
break
except KeyError:
continue
Alternatively, drop the numbers and have a dictionary of lists (where the order of the list is the current league order):
import numpy as np
teams = {'NFL': ["Arizona Cardinals", "Atlanta Falcons", "Baltimore Ravens"],
'NBA': ['Washington Wizards', 'Charlotte Hornets', 'Atlanta Hawks'],
'MLB': ['Los Angeles Dogers', 'Cincinnati Reds', 'Toronto Blue Jays']}
def standings(team):
for league, teams_list in teams.items():
if team in teams_list:
print(team, np.where(np.array(teams_list)==team)[0])
print(league)
Raising and catching exceptions costs much more computationally wise, try to avoid as much as possible
– Aaron_ab
Dec 31 '18 at 7:12
add a comment |
Are the numbers used as keys important?
Would it make sense to have read them into the dictionaries the other way around? - then you can use a try except KeyError statement. This might be preferable for very large dictionaries (though this won't be the case here for teams in a league). It also might be a more object orientated way of thinking: the team name is the object identifier, whilst (I presume the numbers are current league positions?) league position is a property (and a changeable one at that). So for example (adapting Aaron_ab's answer)
teams = {'NFL': {"Arizona Cardinals":1, "Atlanta Falcons":2, "Baltimore Ravens":3},
'NBA': {'Washington Wizards':1, 'Charlotte Hornets':2, 'Atlanta Hawks':3},
'MLB': {'Los Angeles Dogers':1, 'Cincinnati Reds':2, 'Toronto Blue Jays':3}}
def standings(team):
for league, teams_dict in teams.items():
try:
teams_dict[team]
print(teams_dict[team], team)
print(league)
break
except KeyError:
continue
Alternatively, drop the numbers and have a dictionary of lists (where the order of the list is the current league order):
import numpy as np
teams = {'NFL': ["Arizona Cardinals", "Atlanta Falcons", "Baltimore Ravens"],
'NBA': ['Washington Wizards', 'Charlotte Hornets', 'Atlanta Hawks'],
'MLB': ['Los Angeles Dogers', 'Cincinnati Reds', 'Toronto Blue Jays']}
def standings(team):
for league, teams_list in teams.items():
if team in teams_list:
print(team, np.where(np.array(teams_list)==team)[0])
print(league)
Are the numbers used as keys important?
Would it make sense to have read them into the dictionaries the other way around? - then you can use a try except KeyError statement. This might be preferable for very large dictionaries (though this won't be the case here for teams in a league). It also might be a more object orientated way of thinking: the team name is the object identifier, whilst (I presume the numbers are current league positions?) league position is a property (and a changeable one at that). So for example (adapting Aaron_ab's answer)
teams = {'NFL': {"Arizona Cardinals":1, "Atlanta Falcons":2, "Baltimore Ravens":3},
'NBA': {'Washington Wizards':1, 'Charlotte Hornets':2, 'Atlanta Hawks':3},
'MLB': {'Los Angeles Dogers':1, 'Cincinnati Reds':2, 'Toronto Blue Jays':3}}
def standings(team):
for league, teams_dict in teams.items():
try:
teams_dict[team]
print(teams_dict[team], team)
print(league)
break
except KeyError:
continue
Alternatively, drop the numbers and have a dictionary of lists (where the order of the list is the current league order):
import numpy as np
teams = {'NFL': ["Arizona Cardinals", "Atlanta Falcons", "Baltimore Ravens"],
'NBA': ['Washington Wizards', 'Charlotte Hornets', 'Atlanta Hawks'],
'MLB': ['Los Angeles Dogers', 'Cincinnati Reds', 'Toronto Blue Jays']}
def standings(team):
for league, teams_list in teams.items():
if team in teams_list:
print(team, np.where(np.array(teams_list)==team)[0])
print(league)
answered Dec 30 '18 at 22:57
J.WarrenJ.Warren
138119
138119
Raising and catching exceptions costs much more computationally wise, try to avoid as much as possible
– Aaron_ab
Dec 31 '18 at 7:12
add a comment |
Raising and catching exceptions costs much more computationally wise, try to avoid as much as possible
– Aaron_ab
Dec 31 '18 at 7:12
Raising and catching exceptions costs much more computationally wise, try to avoid as much as possible
– Aaron_ab
Dec 31 '18 at 7:12
Raising and catching exceptions costs much more computationally wise, try to avoid as much as possible
– Aaron_ab
Dec 31 '18 at 7:12
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53981104%2fpython-generating-a-new-name-based-on-value-in-multiple-dictionary%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
You basically want to get the name of the variable that holds the data. You can't do this (well, not without some weird trickery), but you can just make a dictionary of dictionaries, where the keys would be the names of the teams, and the values - your original dictionaries (which can be simply lists, BTW).
– ForceBru
Dec 30 '18 at 20:22