0

How to solve this one?

Currently trying to do this task, but can't really do it. Basically, there is a file with numbers, separated with spaces. I need to add full cubes into this list, and then not full cubes. Then I also need to print path, time of creation and how many memory takes (this part is solved) Code : f_name = input('Введіть назву файлу: ') import os def fullcube(n): n = f_name.read() x = int(n)**(1/3) x = int(round(x)) if x**3 == n: return(n) def notfullcube(n): n = f_name.read() y = (n)**(1/3) y = int(round(y)) if y**3 != n: return(n) file = open(f_name, 'r') f = file.read() file.close() cubef = list(map(fullcube(n), f.split())) ncubef = list(map(notfullcube(n), cubef)) fi = open(f_name, 'a') while ch < len(cubef): fi.write('\n'+(str(cubef[ch])+'')*int(ncubef[ch])) fi.close() print(os.path.abspath(f_name)) print(os.path.getctime(f_name)) print(os.path.getsize(f_name))

29th Dec 2020, 8:22 PM
vlad the big boi
vlad the big boi - avatar
2 Antworten
0
"while ch < len(cubef): fi.write('\n'+(str(cubef[ch])+'')*int(ncubef[ch]))" what is "ch"? I can't see where you've declared it and your not incrementing it.
29th Dec 2020, 8:50 PM
rodwynnejones
rodwynnejones - avatar
0
It's kind of redundant, I forgot to remove it
29th Dec 2020, 8:55 PM
vlad the big boi
vlad the big boi - avatar