Новый курс! Каждый программист должен знать генеративный ИИ!
Попробуйте бесплатный урок+ 5
Files
Hello, does someone know how to do this problem? I’m doing it wrong Tom has done pull ups every day and recorded his results. He recorded each day's results in a new line, so that each line represents each day he has done pull ups. Create a program that takes n number as input and outputs the n-th days result (starting from 0). Sample Input 4 Sample Output Day 4, 9 pull ups https://code.sololearn.com/cY5JO78lf4OG/?ref=app
9 ответов
+ 10
needed change:
print(file.readlines()[n])
+ 5
file = open("/usercode/files/pull_ups.txt")
n = int(input())
#your code goes here
output = file.readlines()[n]
output = output.replace("\n", "")
print(output)
file.close()
+ 1
correct code
file = open("/usercode/files/pull_ups.txt",'r')
n = int(input())
n >= 0
print(file.readlines()[n])
file.close()
0
I didn't do it the way the others did it, but there is another way to do it.
file = open("/usercode/files/pull_ups.txt")
n = int(input())
#your code goes here
def pupvalfind(n):
a=0
puval=""
while True:
a+=1
pupval=file.readline()
if(a==n+1):
return(pupval)
break
else:
continue
print(pupvalfind(n))
file.close()
0
# Full answer
file = open("/usercode/files/pull_ups.txt")
n = int(input())
print(file.readlines()[n])
file.close()
0
file = open ("/usercode/files/pull_ups.txt")
b = int(input())
a = file.readlines()
for b in a:
print(a)
file.close
it would tell you how many values in the file
0
file = open("/usercode/files/pull_ups.txt")
n = int(input())
#your code goes here
output = file.readlines()[n]
output = output.replace("\n", "")
print(output)
file.close()
0
Right answer is :
file = open("/usercode/files/pull_ups.txt")
n = int(input())
#your code goes here
output = file.readlines()[n]
output = output.replace("\n", "")
print(output)
file.close()
- 1
file = open("/usercode/files/pull_ups.txt")
n = int(input())
#your code goes here
print(file.readlines()[n]+"\n")
file.close()