Attempts to remove characters from the string that are not numbers. Unfortunately, I cannot do this due to a reason. I also tried "del file[i][j]", unfortunately without.
Code:
file_open = open("napisy.txt","r")
wyniki = open("wyniki4.txt","w")
file = file_open.read().split()
file1 = file
print(file)
cyfry = ['0','1','2','3','4','5','6','7','8','9']
cyfry_zad3 = ''
licznik_cyfr = 0
tab = []
for i in range(0,len(file1)):
for j in range(0,len(file1[i])):
if file1[i][j] not in cyfry:
file1.remove(file1[i][j])
#del file1[i][j]
print(file1)
result
>Solution :
You can use this
file_open = open("napisy.txt","r")
file = file_open.read()
file_open.close()
for char in list(file):
if char not in "1234567890":
file = file.replace(char, "")
