9 AnswersNew Answer
Arun Venkatesh.N , are these inputs numbers (int or float) or strings or a mixture of them? what should happen with numbers? should they be converted from string to int or float? maybe you can do an input sample? >>> have you already done a try that you can link here?
Thank you all finally I got it
What are those inputs? Take input and split into need accordingly...
a = input(); b=input(); print(a,b)
Lothar, For example to get , a set of numbers with spaces in one line as ... 8 5 6 7 9 Like this....what syntax we use
You can split input by space using split(<delimiter>) method and convert values of return list into integers.. input().split(' ') # split with space or lst = input().split() # returns list of words, type str. Next you can use loop or a map function to convert list of integers. lst[i] = int( lst[i] ) in loop or by map map(int, lst) try : print( list( map(int, input().split()) ) )
import numpy as np #call module numpy for array #declared variable x to put number with espaclly with split x=input().split() #create a list to convert all string in integre to add in list list= #using loop to get all values put for i in x : j=int(i) # convert string in integre list.append(j) #add all values into list arr=np.array(list) production=arr.prod() print(production)
You can use lists to take multiple inputs, without having to use input statement multiple times. Try the following code: a=list(map(int,input().split())) The split() function will split the function based on the delimiting character given in parameters. If no parameters are given, it will split the input where the whitespace occurs. map() just converts every single part of the input into the data type mentioned. It is not always mandatory. And finally, the list() function stores the inputs in list format.
n = 1 while n !=0: n = int(input('valor: ')) print ('end')