I have this part of python code that should read input values from the screen. When it runs, it keeps running forever. I tried CTRL+D as per the search results, but it does not work. This code is given and it works when I submit the code to an online grader but does not work on my windows machine.
if __name__ == "__main__":
data = list(map(int, sys.stdin.read().split()))
n, capacity = data[0:2]
values = data[2:(2 * n + 2):2]
weights = data[3:(2 * n + 2):2]
opt_value = get_optimal_value(capacity, weights, values)
print("{:.10f}".format(opt_value))
Sample input should be:
3 2
20 50
12 12
51 51