-3

I have a filename named hosts_access_log_00.txt that I take in from user input like filename = input()

I need to write some output to another filename called records_host_access_log_00.txt where the host_access_log_00.txt comes from filename.

How can I create this filename with this specific name? (i.e. prepending "records" to the filename)

John Kugelman
  • 349,597
  • 67
  • 533
  • 578
Krithika Raghavendran
  • 457
  • 3
  • 10
  • 25

1 Answers1

0

Just string format would be helpful.

'records_%s' % filename

tianhua liao
  • 655
  • 5
  • 9
  • I tried this, it doesn't work. – Krithika Raghavendran Oct 04 '18 at 03:02
  • Or just plain concatenation, since they're both strings already: `'records_' + filename`. – ShadowRanger Oct 04 '18 at 03:02
  • 2
    @KrithikaRaghavendran: "Doesn't work" is the least helpful possible comment. If it doesn't work, tell us how it fails. Tell us what you expected, what you got, including tracebacks if you got an exception. Edit this into your question; if your problem is "my code doesn't work", you need to provide a [MCVE], so we're not just guessing at what you're trying to do and failing. – ShadowRanger Oct 04 '18 at 03:04