Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def get_next_person(raw_data):
- first_period = raw_data.find('.')
- second_period = raw_data.find('.', first_period +1)
- person_info = raw_data[:second_period +1]
- return person_info, second_period
- #print get_next_person(example_input)
- def get_all_persons_info(raw_data):
- persons_info = []
- index_of_persons = []
- while True:
- person_info, second_period = get_next_person(raw_data)
- if person_info:
- persons_info.append(person_info)
- raw_data = raw_data[second_period + 1:]
- else:
- break
- for person in persons_info:
- if (person.split()[0]) not in index_of_persons:
- index_of_persons.append([person.split()[0]])
- return index_of_persons
- #print get_all_persons_info(example_input)
- def get_next_connection(raw_data):
- first_period = raw_data.find('.')
- second_period = raw_data.find('.', first_period +1)
- person_info = raw_data[:second_period +1]
- person = [person_info.split()[0]]
- first_connection = person_info.find('to') + 3
- last_connection = person_info.find('.')
- connections = (person_info[first_connection:last_connection]).split()
- first_game = person_info.find('play') + 5
- last_game = person_info.find('.', first_game)
- games = person_info[first_game:last_game].split()
- games_list = []
- new_games_list = ''
- for word in games:
- if word[-1] != ',':
- new_games_list += word + ' '
- else:
- for letter in word:
- new_word = ''
- if letter != ',':
- new_word += letter
- new_games_list += new_word
- games_list.append(new_games_list)
- #data_structure = [person] + [connections] + [games_list]
- #return data_structure
- return games_list
- print get_next_connection(example_input)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement