Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6334017
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T18:34:41+00:00 2026-05-24T18:34:41+00:00

I have a python code and i want it to make a file where

  • 0

I have a python code and i want it to make a file where it exports what the person wants(for a order). I want to export to a file never created but i want it to be named (the costumer’s name).txt for example John Smith.txt if they said there name was john smith.

My working code requires you to write your filename after python form.py
for example python form.py test.txt would write what the user specified as their info
What i want is the file name to be their name and add the extension .txt
here is my code that works

from sys import argv 
file_name, script = argv
print "Hello I will now ask you for your information.\n"
print "What is your name (last first)?"
name = raw_input() 
print "Alright, what is your adderess? "
address = raw_input()
print "Phone Number"
number = raw_input()
print "Email" 
email = raw_input()
print "fax"
fax = raw_input()
print "Thank you now I will ask you for you vehicle information.\n"
print "Year"
year = raw_input()
print "Make"
make = raw_input()
print "Model"
model = raw_input()
print "Mileage"
mileage = raw_input()
print "vin number"
vin = raw_input()

print "Thank you processing information" 

target = open ("file_name", 'w')

target.write("Information for ")
target.write(name)
target.write("\n")
target.write("name: ")
target.write(name)
target.write("\n")
target.write("Address: ")
target.write(address)
target.write("\n")
target.write("Phone Number: ")
target.write(number)
target.write("\n")
target.write("Email: ")
target.write(email)
target.write("\n")
target.write("Fax: ")
target.write(fax)
target.write("\n")
target.write("\n")
target.write("Vehicle information")
target.write("\n")
target.write("Year: ")
target.write(year)
target.write("\n")
target.write("Make: ")
target.write(make)
target.write("\n")
target.write("Model: ")
target.write(model)
target.write("\n")
target.write("Mileage: ")
target.write(mileage)
target.write("\n")
target.write("Vin Number: ")
target.write(vin)
target.close()
print "Ok done saved info." 
print "\n"
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T18:34:41+00:00Added an answer on May 24, 2026 at 6:34 pm

    If you’re just looking to create a simple file from a variable with a fixed extension:

    myVar="Joe Smart"
    
    x = open (myVar+".txt", "w")
    x.write("hello")
    x.close()
    

    Creates Joe Smart.txt in the current directory. You’d want to do better error checking than I did.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a XML file that I read with Python. I want to make
I have created some python code which creates an object in a loop, and
I have the python code... but how do i do it in c++? I
i want to code in python and i know the syntax well.. but i
If I have Python code class A(): pass class B(): pass class C(A, B):
I have some Python code that works correctly when I use python.exe to run
I have the following Python code: import xml.dom.minidom import xml.parsers.expat try: domTree = ml.dom.minidom.parse(myXMLFileName)
I have some old python code that uses the pywin32 extensions. Starting out with
I have the following Python code: cursor.execute("INSERT INTO table VALUES var1, var2, var3,") where
I have been writing Python code for only a couple of weeks, so I'm

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.