+ 39

How to take two inputs in python

when we click run then how to assign two values in it

26th Aug 2018, 1:53 AM
Arpit Mittal
Arpit Mittal - avatar
10 odpowiedzi
+ 20
a = input() b = input() print(a,b) Now when you run it... Give different input in different lines like - 5 4 #Work done... It'll print : 5 4
26th Aug 2018, 2:07 AM
Nikhil
Nikhil - avatar
+ 30
thank you Nikhil
26th Aug 2018, 2:30 AM
Arpit Mittal
Arpit Mittal - avatar
+ 3
# taking two inputs at a time x, y = input("Enter two values: ").split() print("Number of boys: ", x) print("Number of girls: ", y) print()
27th Feb 2022, 5:48 AM
Vaibhav
Vaibhav - avatar
+ 2
thanks Nikhil
26th Aug 2018, 2:37 PM
Ayan Karar
Ayan Karar - avatar
+ 1
this may also depend on the goals. if you need, for example, a user to enter more than 2 numbers (5, 10 or 100), it's easier for you to work with the lists. you can ask to enter the numbers (exact number of times (5, 10 or 100) = range(5)) and send these numbers to the list: lst = [] for x in range(5): x = int(input()) lst.append(x) #lst = [6, 3, .., .., ..]
9th Sep 2018, 7:24 PM
Polina
Polina - avatar
0
input1 = input("Enter the first input: ") input2 = input("Enter another input: ")
26th Aug 2018, 1:55 PM
Willkizy
Willkizy - avatar
0
Print(a,b)
9th Sep 2018, 3:46 PM
Angie Young
Angie Young - avatar
0
Code example: #We give a 3 and b 4 a = input("Enter Something") b = input("Enter Something") print(a, b) # a = 3, b = 4 As I mentioned Output: 34
10th Nov 2018, 7:21 AM
Jaidee
Jaidee - avatar
- 1
a, b =[int(x) for x in input("Enter two numbers: ").split()]. It's very sophisticated Simpler solution. From my last program: from numpy import * import numpy as np import math as m from itertools import * arrentry=input("Type the numbers wich will form the array: \n") print (arrentry) def conversion(arrentry): arrentry =arrentry.split() limit=len(arrentry) a=np.zeros(limit) dim=int(m.sqrt(limit)) for x in count(0): if x<=limit-1: a[x]=arrentry[x] else: break b=a.reshape((dim, dim)) return b def checking(b): dim=b.shape[0] sw= True for x in range(dim): y=dim-x-1 while x<=y: if b[x][y]!=b[y][x]: sw= False break else: y-=1 return sw print(conversion(arrentry)) print("The array which is over this line, is it owl matrix: ") print(checking(conversion(arrentry))) As you can see, I take the input as it was a string,and then I convert it in a list, an unidimensional array or multidimensional array. I hope you understand me, because my English isn't very good.
7th Sep 2018, 11:23 PM
David Rueda 🇪🇸
David Rueda  🇪🇸 - avatar
- 2
yv
8th Sep 2018, 3:59 PM
adan abdullahi
adan abdullahi - avatar