My code:
for i in sys.stdin.readlines():
lines = i.strip()
for j in range(3):
sys.stdout.write(lines + '
')
Test Case 1:
Input: "Hello, World!"
Expected Output:
Hello, World!
Hello, World!
Hello, World!
Test Case 2:
Input: ""
Expected Output:
Error: line 6, in
sys.stdout.write(lines + '
')
NameError: name 'lines' is not defined
I am so confused because the first test case working fine but in the second test case "lines" is not defined. Please help me elaborating on this error and how to fix it, thank you!
question from:https://stackoverflow.com/questions/65931348/nameerror-name-is-not-defined-only-for-test-case-2