Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
118 views
Welcome To Ask or Share your Answers For Others

1 Answer

Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...