Help me out converting string into Integers in pyhthon 3.5 language

If a=3 and n=input().split()
And there are “a” no. Of values ,means 3 values and how will we convert it into integers

You can do it using list compression as follows:

l=[int(x) for x in input().split()]

Here a is the number of integers, and l is a list in which we store a integers using list compression.

Sample input for above code snippet will be:


4 5 6

1 Like

How will we convert it every no.each time with the loop

Did you mean that you want the input in a single integer variable by looping instead of a list?

If so, you can do as follows:

for x in input().split():