Reputation: 109
I am have a problem trying to get this function to work properly. I need it to write to a text file that includes "First Name: " , then add the input from the entry field at the end of "First Name: ".
def _NameEntry(self):
open("Results.txt", "w").close()
first = self._firstNameEntry.get()
with open("../Results.txt", "a") as the_file:
the_file.write("First Name: ", + first)
But when I use this function it errors this:
"the_file.write("First Name: ", + first) TypeError: bad operand type for unary +: 'str'"
If I get rid of the ("First Name: ", +)
, then it will write the entry field to the text file, whatever the value is.
Upvotes: 0
Views: 224
Reputation: 59274
You have an error in your Syntax.
It should be:
the_file.write("First Name: " + first)
Upvotes: 2