
# This function takes in the list mylist and finds all the indexes that
# store my item, and returns these indexes in a list.
def findlocs(mylist, myitem):

    # Store result here.
    res = []

    # Loop through the indexes of mylist.
    for i in range(len(mylist)):

        # If we have a match, add index i.
        if mylist[i] == myitem:
            res.append(i)

    # Ta da!
    return res
    
scientists = ['tesla', 'einstein', 'newton', 'planck', 'curie', 'einstein']

name = input("Who do you want to remove?\n")

# Safe to remove so do it.
if name in scientists:
    scientists.remove(name)
    print(name,"was successfully removed.")
    print("here is the new list", scientists)

# Print error message.
else:
    print("Sorry,",name,"isn't in the list")

#scientists.sort()
print(scientists)
#scientists.reverse()
print(scientists)

# Slice in middle.
myslice = scientists[2:4]
print(myslice,"is from index 2 to index 4, exclusive")

# slice in beginning
myslice2 = scientists[:3]
print(myslice2,"is from index 0 to index 3, exclusive")

# slice from end
myslice2 = scientists[3:]
print(myslice2,"is from index 3 to end, exclusive")

locs = findlocs(scientists, "einstein")
print(locs,"is where we'll find einstein")
