Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

how to use for loop to take n number of input in python

input_string = input('Enter elements of a list separated by space ')
print("
")
user_list = input_string.split()
# print list
print('list: ', user_list)

# convert each item to int type
for i in range(len(user_list)):
    # convert each item to int type
    user_list[i] = int(user_list[i])

# Calculating the sum of list elements
print("Sum = ", sum(user_list))
Comment

PREVIOUS NEXT
Code Example
Python :: pytest - parameterizing tests 
Python :: pandas astype str still object 
Python :: autopytoexe 
Python :: python input character limit 
Python :: random seed generator minecraft 
Python :: conda enviroment python version 
Python :: solidity compiler for python 
Python :: Replace all the empty rows in the column with the value that you have identified 
Python :: python filter() 
Python :: how to make string bold in python 
Python :: matplotlib draw line x1, y1 
Python :: get vowels from string python 
Python :: len(sys.argv) == 2 
Python :: python regular expressions 
Python :: python string generator 
Python :: sns histplot 
Python :: python check variable size in memory 
Python :: how to specify variable type in python 
Python :: python multiply 2 variables 
Python :: matplotlib legend number columns 
Python :: how to add column to the Dataframe in python 
Python :: how to print in double quotes in python 
Python :: pandas groupby multiple columns 
Python :: Creating Python Sets 
Python :: cmd to get ip address python 
Python :: python excel file 
Python :: scipy check normal distribution 
Python :: pandas selection row/columns 
Python :: Python RegEx Split – re.split() 
Python :: python remove by index 
ADD CONTENT
Topic
Content
Source link
Name
9+8 =