I've tried just about everything and I am stumped. I've tried a million variations of:
for guardians in players:
if "and" in player['guardians']:
guardians.split('and')
"clean the guardian's string so that it becomes a List of strings. Remove the and between the names and storing each guardian in a List together for that player."
PLAYERS = [{
'name': 'Karl Saygan',
'guardians': 'Heather Bledsoe',
'experience': 'YES',
'height': '42 inches'
},
{
'name': 'Matt Gill',
'guardians': 'Charles Gill and Sylvia Gill',
'experience': 'NO',
'height': '40 inches'
},
{ 'name': 'Sammy Adams',
'guardians': 'Jeff Adams and Gary Adams',
'experience': 'NO',
'height': '45 inches'
},
{
'name': 'Chloe Alaska',
'guardians': 'David Alaska and Jamie Alaska',
'experience': 'NO',
'height': '47 inches'
},
{
'name': 'Bill Bon',
'guardians': 'Sara Bon and Jenny Bon',
'experience': 'YES',
'height': '43 inches'
},
{
'name': 'Joe Kavalier',
'guardians': 'Sam Kavalier and Elaine Kavalier',
'experience': 'NO',
'height': '39 inches'
},
{
'name': 'Phillip Helm',
'guardians': 'Thomas Helm and Eva Jones',
'experience': 'YES',
'height': '44 inches'
}
]
question from:
https://stackoverflow.com/questions/65838504/removing-word-from-string-nested-in-dictionary-within-a-list 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…