+ 1
Code Coach | New driver license
So i was doing the new driver license challenge and this is my code: def time(name, agents, other_names): name_list = other_names.split(" ") name_list.append(name) name_list.sort() people_ahead = name_list.index(name) waves = people_ahead / agents time_to_wait = waves * 20 time_to_wait += 20 return time_to_wait ââââââââââââââââââââââ- for some reason all of my outputs are none. please i need some help somebody can explain this what am i missing? Thanks you
9 Antworten
+ 1
Was def time included in the code?
+ 1
what do you mean?
+ 1
ok i know why im wrong thankss
+ 1
What is the correct input to correct the error in the code let others learn from you.
+ 1
This code help you
name = input(" ")
agent = int(input(" "))
a,b,c,d = input(" ").split(" ")
drivers = [a,b,c,d,name]
drivers.sort()
pos = drivers.index(name)+1
time = 20
if pos <= agent:
print(time)
else:
rd = pos-agent
if rd > agent:
rdiff = rd - agent
p = (rdiff*20) + 20
print(p+time)
else:
print(time+20)
0
Try taking input rather than parameter in the function.
0
license_time = 20
me = input()
agents = int(input())
clients = input().split()
clients.append(me)
clients.sort()
waiting_time = ((clients.index(me))
// agents + 1) * license_time
print(waiting_time)
0
myname = input()
num_agents = int(input())
other_names = list(input().split())
other_names.append(myname)
other_names.sort()
ind_myname = other_names.index(myname)+1
print('20' if ind_myname <=num_agents else (ind_myname-num_agents)*20+20)