Reputation: 6476
I am a Python 2.7 user who recently switched to python3. While reading integers separated by a blackspace/endline I used nex = iter(map(int,stdin.read().split())).next
, where nex()
acts as a function to input integers (Suppose for inputting an integral value in x -> x=nex()
. But in python3 this doesn't seem to work. Someone please propose a workaround for using the same in Python3.
Upvotes: 0
Views: 36
Reputation: 414179
.next()
method is called .__next__()
in Python 3. You could use next()
function to write single-source Python 2/3 compatible code:
from functools import partial
nex = partial(next, iter(iterable))
print(nex())
Upvotes: 1