How do i take formatted input in python? -


i want take input 7 8 9 5 12 17 separate integers in array ar[]. have tried a=input() ar.append(a.split(" ")) stores numbers strings. , can't find way convert these integers directly while appending. please in advance.

to create proper python list object, can do

ar = [int(i) in input().split()] 

otherwise, way

ar = map(int, input().split()) 

you can strip whitespace if needed. do

ar = map(int, input().strip().split()) 

Comments