I have been playing with Python for almost five days and I honestly enjoy it.
I have this challenge and I couldn't solve it.
The challenge is to repeat the output of top command every 10 seconds and save it into a file.
Here is what I have done so far.
import time, os, threading
def repeat():
print(time.ctime())
threading.Timer(10, repeat).start()
f = open('ss.txt', 'w')
top = os.system("sudo top -p 2948")
s = str(top)
text = f.write(s)
print(text)
repeat()