def drinking_with_friend(friends_list):
try:
data = friends_list.pop(0)
except IndexError:
print('There are no more sober friends')
return False
interval = random.random() * 10
print('Start Drinking with {:>20} time for drinking (duration {} )'.format(data, interval))
time.sleep(interval)
print('Finish Drinking with {:>19} time for drinking (duration {} )'.format(data, interval))
Start Drinking with Vasya time for drinking (duration 0.525207635674314 )
Start Drinking with Petya time for drinking (duration 8.101208126205927 )
Start Drinking with Kolya time for drinking (duration 5.656888553205503 )
Start Drinking with Sasha time for drinking (duration 9.985692547228792 )
Finish Drinking with Vasya time for drinking (duration 0.525207635674314 )
Start Drinking with Ivan time for drinking (duration 6.944745503696382 )
Finish Drinking with Kolya time for drinking (duration 5.656888553205503 )
Start Drinking with Alex time for drinking (duration 8.269980798554679 )
Finish Drinking with Ivan time for drinking (duration 6.944745503696382 )
Start Drinking with Semen time for drinking (duration 7.068649522212147 )
Finish Drinking with Petya time for drinking (duration 8.101208126205927 )
Start Drinking with Goga Aka Gosha time for drinking (duration 5.178367620321175 )
Finish Drinking with Sasha time for drinking (duration 9.985692547228792 )
There are no more sober friends
There are no more sober friends
Finish Drinking with Goga Aka Gosha time for drinking (duration 5.178367620321175 )
Finish Drinking with Alex time for drinking (duration 8.269980798554679 )
Finish Drinking with Semen time for drinking (duration 7.068649522212147 )
pop()
получат IndexError
и умрут, ну лучше так не делает и обрабатывать исключение и нормально завершать процесс.
2. Где ваш код, в котором вы пытаетесь реализовать это?