Like this: Show
You can't do this in a one-liner (or at least not without some super duper extra hackz0r skills -- or semicolons), but python is not made for one-liners. answered Nov 12, 2010 at 8:35
Gabi PurcaruGabi Purcaru 30.2k9 gold badges76 silver badges91 bronze badges One liner :)
answered Nov 12, 2010 at 8:44
1 Simpler one liner(but less secure):
answered Sep 2, 2013 at 20:27
0 If the input is separated by spaces " "
If the input is separated by comma ','
alex 5,2694 gold badges33 silver badges43 bronze badges answered Aug 6, 2016 at 5:56
In Python 2.7, I use this
Output:
answered Apr 3, 2017 at 8:20
JasmohanJasmohan 2273 silver badges5 bronze badges
ρss 4,9778 gold badges42 silver badges71 bronze badges answered Jan 31, 2016 at 17:45
0 Below snippet works for me.
answered Dec 16, 2020 at 4:24
If you wish to take as many inputs as u want then following:
If you want two inputs:
answered Jul 11, 2019 at 19:10
semssems 212 bronze badges 1 This is good solution imho If you want to separate input with custom character you can put it in parenthesis e.g. answered Sep 16, 2019 at 2:44
Read 3 inputs separated by space...
answered Dec 2, 2019 at 13:45
Python 3.5Below snippet works for me.
answered Dec 15, 2019 at 10:56
vijayraj34vijayraj34 1,65822 silver badges24 bronze badges Basically you just need to use map function and pass user define function for which datatype you need to convert. code You can even use it to convert it into other datatypes as well answered Jan 12, 2021 at 5:25
1 In python 3 we can use,
answered Jan 23 at 5:31
1 How do you read two space separated integers in python?Thanks. Easy solution is just to use the string method split. input: 5 8 0 sgshsu 123 input. split(" ") == ["5", "8", "0", "sgshsu", "123"] #Then they are easy to convert to numeric datatypes, but invalid inputs might raise errors.
How do you take space separated inputs?There are 2 methods to take input from the user which are separated by space which are as follows: Using BufferedReader Class and then splitting and parsing each value. Using nextInt( ) method of Scanner class.
How do you take space separated input in for loop in Python?how to get user input of list of lists in python. lst = [ ]. n = int(input("Enter number of elements : ")). for i in range(0, n):. ele = [input(), int(input())]. lst. append(ele). print(lst). How do you read a string with spaces in Python?Python String isspace() method returns “True” if all characters in the string are whitespace characters, Otherwise, It returns “False”. This function is used to check if the argument contains all whitespace characters, such as: ' ' – Space.
|