-1

I can't figure out how to create a dictionary that will be based on an input of a list of whole numbers (no problem with getting the input) and have the list indexes as keys and input data as values.

For example if the input is [75, 48, 23, 89] then the end result should be [(0, 75), (1, 48), (2, 23), (3, 89)].

lmiguelvargasf
  • 63,191
  • 45
  • 217
  • 228

2 Answers2

1

Use enumerate and convert the result to a list as follows:

l = # your list
new_list = list(enumerate(l))
lmiguelvargasf
  • 63,191
  • 45
  • 217
  • 228
-1

I'm not 100% sure if I understood your question right but this would generate a dict with the index of the list as keys and their values as values.

lst = [75, 48, 23, 89]

d = dict(zip(list(range(len(last))), lst))