# Entry of type "float" to a python file?

Recently started to learn python...
spoiler
There is a file with data on progress of students. It is a set of lines, where each line contains the following information:

Name;Otsenkami;Ozankoy;Otsenkami

Fields within the line separated by a semicolon, scores are integers.

Write a program that reads a file with similar structure and for each applicant brings his average score on these three items on a line corresponding to this applicant.

In response to a task attach the resulting file with average ratings.

If brief then print the average GPA for each student, but when writing to a file float integer zero after the decimal point there.
here is the code
``````#!/bin/python3
with open('1.txt') as txt, open('2.txt','w') as out:
for p in range(s.count('\n')+1):
print ((float(s)+float(s)+float(s))/3)#how should be the file
out.write((float(float(s)+float(s)+float(s))/3))#writing to a file
out.write('\n')
with open('2.txt','r') as out:
print(g)#print to file``````

Why is this happening? How to fix?

Petrov;85;92;78
Sidorov;100;88;94
Ivanov;58;72;85

Sample Output:
85.0
94.0
71.666666667
April 4th 20 at 13:22
April 4th 20 at 13:24
Solution
What a strange mess you have
``````for line in open('1.txt', 'r', encoding='utf-8'):
data = line.strip().split(';')
name, grades = data, [int(x) for x in data[1:]]
if avg == int(avg):
avg = int(avg)
open('2.txt', 'a').write(f,'{avg}\n')``````
Thanks, you explanation of what it means to`write(f'{avg}\n')` - Madisen86 commented on April 4th 20 at 13:27
@Madisen86, one of the methods of string formatting - faustino_Koepp55 commented on April 4th 20 at 13:30
@Madisen86, I just don't quite understand the zeros in the fractional numbers in the output, or not. If needed, then just delete the line
``````if avg == int(avg):
avg = int(avg)``````
- faustino_Koepp55 commented on April 4th 20 at 13:33
Don't need) OK, thanks. - Madisen86 commented on April 4th 20 at 13:36
April 4th 20 at 13:26
``````#!/bin/python3
with open('1.txt') as txt, open('2.txt','w') as out: