Skip to content Skip to sidebar Skip to footer

Typeerror: Write() Argument Must Be Str, Not Int

Below is my code for a in list(range(1,100)): print(a) with open('C:/Users/me/Downloads/Documents/lala',mode='w')as f: print(f.write(a)) Error is: TypeErr

Solution 1:

You need to convert a to a string before you write it with

str(a)

You should also remove the print call as there should be nothing to print from your file operation

f.write(str(a))

Post a Comment for "Typeerror: Write() Argument Must Be Str, Not Int"