Bottom Page

Thread Rating:
  • 3 Vote(s) - 3.67 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 Accept Multiple Lines of Input into a User Created File
The problem starts when, from the terminal, as an example, the user cuts and pastes the following:


When I open the user created file I want to see, as a column:


However, only the first line is accepted into the file. I know I'm using raw_input and it only accepts a single how can I use the code for a user created file and somehow get multiple lines into that file?

I tried sys.stdin as well as trying to open targetfile as f but multi-line input won't get into the user created file.
There are no traceback errors.

import os
#import sys

#user creates a file name
targetfile = raw_input('Enter Subject of email here: ')

things_list =

#if user enters input on multiple lines script doesn't send input to targetfilefound, it doesnt quit when type done either
things = raw_input("Enter things, then type 'done' on its own line to quit: \n")

while True:
targetfilefound = open(targetfile , 'w')
while things != "done":
things = raw_input("")
things_list = ''.join(things_list)

except KeyboardInterrupt:
sparkz_alot wrote Oct-29-2017, 07:54 PM:
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post.

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  if the input is not number, let user input again teatea 14 369 Jun-02-2020, 07:03 PM
Last Post: ibutun
  How to allow user input only if certain requirements are met vininhosts 3 141 May-28-2020, 06:15 PM
Last Post: micseydel
  I need my compiled Python Mac app to accept a file as a parameter Oethen 2 243 May-10-2020, 05:57 PM
Last Post: Oethen
  Split and sort input file aawaleh 4 245 Apr-10-2020, 09:59 PM
Last Post: aawaleh
  Python - Most effective way to correct keyboard-user-input. ppel123 8 282 Apr-08-2020, 07:41 AM
Last Post: ppel123
  User input & Dictionary tfernandes 5 314 Apr-03-2020, 07:12 PM
Last Post: tfernandes
  Taking Multiple Command Line Argument Input bwdu 6 267 Mar-29-2020, 05:52 PM
Last Post: buran
  User Input and CSV File Davy_Jones_XIV 2 281 Mar-24-2020, 08:43 AM
Last Post: Davy_Jones_XIV
  user input producing incorrect boolean al_Czervik 4 276 Mar-05-2020, 09:50 PM
Last Post: al_Czervik
  print python json dump onto multiple lines lhailey 2 3,672 Mar-02-2020, 12:47 PM
Last Post: vishalhule

Forum Jump:

Users browsing this thread: 1 Guest(s)