Reputation: 25
it's supposed to add a and b after you type them , example is 2
,5
,it should return 7
.
import sys
input = sys.stdin.read()
tokens = input.split()
a = int(tokens[0])
b = int(tokens[1])
print(a + b)
But, when i run it, it's just stuck and it doesn't do anything , i type the numbers and it doesn't do anything.
Is it because i'm using the 3.5 version?
Upvotes: 1
Views: 60
Reputation: 504
No, sys.stdin.read()
will read until the stream ends (you can press Ctrl-D to send the Signal)
use input()
.
(Also, don't use input, or any other keywords or standard methods as a variable name.)
Upvotes: 3