Q. We're using lists to record people who attended our party and what order they arrived in. For example, the following list represents a party with 7 guests, in which Adela showed up first and Ford was the last to arrive:
party_attendees = ['Adela', 'Fleda', 'Owen', 'May', 'Mona', 'Gilbert', 'Ford'] A guest is considered 'fashionably late' if they arrived after at least half of the party's guests. However, they must not be the very last guest (that's taking it too far). In the above example, Mona and Gilbert are the only guests who were fashionably late.
Complete the function below which takes a list of party attendees as well as a person, and tells us whether that person is fashionably late.
My Ans:
def fashionably_late(arrivals, name):
"""Given an ordered list of arrivals to the party and a name, return whether the guest with that
name was fashionably late.(This is a hint by the website.)
"""
name_index=arrivals.index(name) #This line of code is working fine.
final_index_of_list=arrivals.index((len(arrivals)-1)
print(final_index_of_list)
if final_index_of_list%2==0:
return False if name_index<=(final_index_of_list/2) or name_index==final_index_of_list else True
else final_index_of_list%2>0:
return False if name_index<=(final_index_of_list/2+1) or name_index==final_index_of_list else True
Error Message:
File "<ipython-input-16-d4bcd37e23f2>", line 7
print(final_index_of_list)
^
SyntaxError: invalid syntax