In online contests, when the length of input is not specified and reading the input file directly through the program is not possible, one can use this code in C++:
while (cin >> var)
{
//do something with var
}
What's the equivalent for python?
- Without using any file-related function such as
open() write() ...
write the following code
while True: a=input() if(a==''): break else .....
.in else part you write the code which wants to execute and if you want to use int in your code convert it in int and use that
There's no direct equivalent in Python. But you can simulate it with two nested loops:
If you need something other than a string you'll need to convert it in a separate step:
This could be helpfull.