+ 1

Someone help me with a syntax in python...

How to get multiple input in one line using python?

22nd Sep 2022, 6:53 AM
Venkatesh
Venkatesh - avatar
9 Antworten
+ 5
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?
22nd Sep 2022, 10:06 AM
Lothar
Lothar - avatar
+ 5
Thank you all finally I got it
23rd Sep 2022, 6:20 AM
Venkatesh
Venkatesh - avatar
+ 4
What are those inputs? Take input and split into need accordingly...
22nd Sep 2022, 7:52 AM
Jayakrishna 🇮🇳
+ 3
a = input(); b=input(); print(a,b)
22nd Sep 2022, 7:13 AM
JaScript
JaScript - avatar
+ 2
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
22nd Sep 2022, 11:22 AM
Venkatesh
Venkatesh - avatar
+ 2
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()) ) )
22nd Sep 2022, 12:14 PM
Jayakrishna 🇮🇳
+ 1
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)
22nd Sep 2022, 11:14 PM
ALI Moussa Kadjalla
ALI Moussa Kadjalla - avatar
+ 1
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.
23rd Sep 2022, 1:16 AM
Naveen Togu
Naveen Togu - avatar
0
n = 1 while n !=0: n = int(input('valor: ')) print ('end')
23rd Sep 2022, 6:12 PM
Datan Aguiar
Datan Aguiar - avatar