Question: I am a bit new to Python, and trying to do something simple I'm sure. I want to ask someone their name as the initial raw\_input and then I want that name to be used to create a file. This is so that any additional raw\_input taken from that user it gets recorded to that file.

```
raw_input("What is your name?")
file = open("newfile.txt", "w") 

```

I have the above code that will create a file called newfile.txt, but how can I make it so that the requested name will be used as the file name?
Thank you!

```
file = open("user.txt", "w")

```

Answer: 
Save the name in a variable and use it :

```
name = raw_input("What is your name?")
file = open(name+".txt", "w") 
...
file.close()

```
Following should work - 

```
user_input = raw_input("What is your name?")  # Get user's input in a variable
fname = user_input + '.txt'   # Generate a filename using that input
f = open(fname, "w")   # Create a file with that filename
f.write('')
f.close()

```