Help with Safety deposit box in python | Sololearn: Learn to code for FREE!

0

Help with Safety deposit box in python

Having trouble with this activity about safety deposit boxes. Trying my best at python. It returns the index of the second test as 5 when I expect 1🤔 Any advice will be appreciated. https://www.sololearn.com/coach/17?ref=app My code: items = input() box = input() index = items.index(box) time = (index + 1) * 5 print(time)

4/19/2021 8:12:39 PM

André Dreyer

2 Answers

New Answer

+1

Safety Deposit Boxes You are robbing a bank, but you’re not taking everything. You are looking for a specific item in the safety deposit boxes and you are going to drill into each one in order to find your item. Once you find your item you can make your escape, but how long will it take you to get to that item? Task Determine the amount of time it will take you to find the item you are looking for if it takes you 5 minutes to drill into each box. Input Format A string that represent the items in each box that will be drilled in order (items are separated by a comma), and secondly, a string of which item you are looking for. Output Format An integer of the amount of time it will take for you to find your item. Sample Input 'gold,diamonds,documents,Declaration of Independence,keys' 'Declaration of Independence' Sample Output 20

0

First my idea: ✅ ............................................................. item = input().split(",") desire = input() for i in item: if i == desire: print(5 * (item.index(i) + 1)) ............................................................. ............................................................ Second pro idea:✅ ............................................................. items = input().split(',') desired = input() time = 5 * (1 + items.index(desired)) print (time) .............................................................