Skip to content

Instantly share code, notes, and snippets.

@mayankdawar
Created August 7, 2020 20:55
Show Gist options
  • Save mayankdawar/ca549f2228ca109dfbfafa25816e8d27 to your computer and use it in GitHub Desktop.
Save mayankdawar/ca549f2228ca109dfbfafa25816e8d27 to your computer and use it in GitHub Desktop.
Given below is a list of lists of athletes. Create a list, t, that saves only the athlete’s name if it contains the letter “t”. If it does not contain the letter “t”, save the athlete name into list other.
t = []
other = []
athletes = [['Phelps', 'Lochte', 'Schooling', 'Ledecky', 'Franklin'], ['Felix', 'Bolt', 'Gardner', 'Eaton'], ['Biles', 'Douglas', 'Hamm', 'Raisman', 'Mikulak', 'Dalton']]
for lst in athletes:
for name in lst:
if 't' in name:
t.append(name)
else:
other.append(name)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment