Reading from the console and writing to it is a piece of cake in python. These two functions do it for you perfectly:
1 2 |
a = input() print(a) |
Then why am I writing a whole article about it? Well, there is something fancy, if you need to read and write more than that. E.g., if you are reading 4 numerical integers, splitted by a comma, then most probably you will not think about the following fancy options immediately. Or if you want to write from a list of different values, and to split by some other separator. Anyway, this article is mainly for me, with the idea to update it with the time, when needed. Enjoy it!
Reading
1 |
a, b, c, d = [int(x) for x in input().split(', ')] |
Writing
1 2 3 |
a = [1,2,3,454,'foo', [23,4]] print(*a, sep='==') # 1==2==3==454==foo==[23, 4] |