Generation

generate functionTue, 13 Dec 2022

Create a function with two variables. The first variable will take a list. The second variable should output the value from that list by index. If the second variable is longer than the list length, it should not print an error but re-list the list. ([a, b, c, d], 1) should return a ([a, b, c, d], 4) should return d ([a, b, c, d], 5) should return a

def find_index(lst, ind): return lst[ind % len(lst)] find_index(["a", "b", "c", "d"], 1)

Questions about programming?Chat with your personal AI assistant