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:

a=int(input())
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:

3

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:


a=int(input())
for x in input().split():
	variable=int(x)