TypeError: must be str, not float
python, string
Solution
If you're using Python 3.x (it's possible you might be given your `print`), then instead of using `.write` or string formatting, an alternative is to use:
print('Your Skill:', charskill, file=myFile)
This has the advantage of putting a space in there, and a newline character for you and not requiring any explicit conversions.
Problem
this is 1/8 of my script: ``` print('Your skill:', int(charskill)) with open('C:\Documents and Settings\Welcome\My Documents\python\Task 2\lol.txt', 'w') as myFile: myFile.write(charskill) ``` Once I execute on python, it gives me an error of: ``` Traceback (most recent call last): File "C:\Documents and Settings\Welcome\My Documents\python\Task 2\Dice generator v2.py", line 39, in <module> myFile.write(charskill) TypeError: must be str, not float ``` How do I fix this problem? I want the file to run on notepad ;/ because it is my homework at school.