how to take space separated input in pyhon dicationary code example

Example 1: take space separated int input in python

inp = list(map(int,input().split()))

Example 2: python space separated input

l = list(map(int,input().split())

Example 3: how to take space separated input in python

_input = input() # Get input
_input = "thing1 thing2, thing3"
space_split = _input.split() # ["thing1", "thing2,", "thing3"]
comma_split = _input.split(",") # ["thing1 thing2", "thing3"]

Example 4: how to take space separated input in pyhon dicationary

dic = {}
for index, value in enumerate(input().split()):
    dic[int(value)] = int(index)

Tags:

Misc Example