0

New Driving License (Test case 5 Failed )

#Test case Failed !! NEED HELP!! name = str(input()) num_agents = int(input()) people = list(input().split(" ")) people.append(name) new_list = sorted(people) if num_agents >= int(new_list.index(name)): print(20) elif num_agents == 1: print(20*(int(new_list.index(name)+1))) else: if num_agents == 2: if 2 <= new_list.index(name) <= 3: print(40) else: print(60) else: print(40)

11th Jun 2020, 1:23 PM
Nikhil Jain
Nikhil Jain - avatar
3 Respostas
+ 1
first if statement starts indexing from 0. Use:if num_agents >= int(new_list.index(name)+1)
11th Jun 2020, 1:38 PM
Justus
Justus - avatar
+ 1
Justus i forgot to add +1 when using index.. Thanku you
11th Jun 2020, 2:12 PM
Nikhil Jain
Nikhil Jain - avatar
0
What happens in your code, then num_agents is 3 or 4?
11th Jun 2020, 1:33 PM
Igor Kostrikin
Igor Kostrikin - avatar