0

What am I doing wrong?

file = open("/usercode/files/pull_ups.txt", "r") n = int(input()) b=n-1 print(file.read(b)) file.close() Why i don't have output?

25th Feb 2021, 9:12 AM
Bartosz Bryniak
Bartosz Bryniak - avatar
2 Answers
+ 5
Because file.read() reads a specific number of bytes in the file, not line. file.read(bytes) That is why it won't return anything since as far as I know in that challenge, the output is the day no. which are small numbers. You can use file.readlines() instead to return a list (each line of the file as each element). Then use the input as your index. n = int(input()) print(file.readlines()[n])
25th Feb 2021, 9:18 AM
noteve
noteve - avatar
+ 2
Thanks
25th Feb 2021, 9:38 AM
Bartosz Bryniak
Bartosz Bryniak - avatar