Writing strings into a new file not working


#1

Hello, I am trying to write strings into a new file and I am getting a TypeError: unsupported operand type(s) for +: ‘set’ and ‘set’

here is the code

from sys import argv

script, filename = argv

print(“hello user”)
name = input(“what’s your name?”)

print (f"hello {name}")

last_name = input(“and what’s your last name?”)

print(f"Oh great. I have heard about you, {name} {last_name}.")

assumption = input("What’s your favorite thing in the world ")

target = open(filename,‘w’)
target.truncate()

target.write({name} + {last_name} + {assumption})

target.close()


#2

Like your error message says, sets don’t support addition, nothing to do with files or strings
Also, if anyone’s to run (or even read, really) your code, you’ll need to ensure that they can get an exact copy of it.


#3

Wow! I am an idiot. Thanks a lot. So this is resolved. Thanks a lot