So thank you! raw download clone embed report print Python 0.68 KB . Then compute and print the result of . 12 34 56 67 78 (12, 34, 56, 67, 78) Continue this thread View entire discussion (5 comments) More posts from the learnpython community.

You can convert a string like '90' to an integer by doing int('90'). What would the code print in the case that input()==0 returns true? 520. [tuple(x.split(' - ') for x in tup) for tup in lst if len(tup) == 1] It splits it up but the other tuples (of len == 2) are missing. n = tuple (map (int, input (). By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. input takes a line as input from the standard input stream.

foo = tuple(int(x) for x in raw_input().split()) Your suggesting works for me with a small change. It is obviously specific to python. Note: hash() is one of the functions in the builtins module, so it need not be imported. Share. You want a tuple of integers. If the separator is not provided then any white space is used as a separator. Sign Up, it unlocks many cool features!. We use cookies for various purposes including analytics. list python. 0 0. OK, I Understand if input != 0: print (hash(tuple(map(int,input().strip().split())))) But the code in question has a boolean operator inside a print statement, comparing a boolean and an int. It breaks the given input by the specified separator. Posted by 2 days ago.
We use cookies for various purposes including analytics. split ())) OK, I Understand Now you want the map function, which can apply a function (the first parameter) to an iterable (the second parameter). Tuples Task. I was looking for a way to create a tuple from input like this. Any suggestions please? Generally, users use a split() method to split a Python string but one can also use it in taking multiple inputs. Input Format.
Not a member of Pastebin yet? This is what I need explained to me. Using map() and split() Method 1: Using List comprehension and split() split() function helps in getting multiple inputs from the user. But here you need to apply that function to a whole list of objects. Given an integer, , and space-separated integers as input, create a tuple, , of those integers. map returns a map … The first line contains an integer, , denoting the number of elements in the tuple.