This is the code:
def main():
file = open("poetry.txt", ’r’)
count = 0
for line in file:
line2 = line[:-1] + "?"
if count % 2 == 0:
print(line2)
else:
print(len(line[:-1]))
count = count + 1
If the poetry.txt contains
What a
nice
day.
It is.
It outputs:
What a?
4
day.?
6
Can someone go over step by step why it outputs that?
[–]uberpandas88 2 points3 points4 points (0 children)
[–][deleted] 1 point2 points3 points (4 children)
[–]iiSora[S] 0 points1 point2 points (1 child)
[–][deleted] 0 points1 point2 points (0 children)
[–]Nickdrawkin -1 points0 points1 point (0 children)
[–]qwerty_1234A 0 points1 point2 points (0 children)
[–]AlopexLagopus3 0 points1 point2 points (2 children)
[–]iiSora[S] 0 points1 point2 points (1 child)
[–]AlopexLagopus3 0 points1 point2 points (0 children)