Python Forum
Quotes and variables in print statement
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Quotes and variables in print statement
#2
One way would be
print('"' + searchfor + '" is in the file.')
but the more pythonic way is using python >= 3.6 and f-strings

print(f'"{searchfor}" is in the file.')
Reply


Messages In This Thread
Quotes and variables in print statement - by Mark17 - Sep-06-2019, 01:58 PM
RE: Quotes and variables in print statement - by ThomasL - Sep-06-2019, 03:36 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  How to print variables in function? samuelbachorik 3 989 Dec-31-2022, 11:12 PM
Last Post: stevendaprano
  Why does absence of print command outputs quotes in function? Mark17 2 1,474 Jan-04-2022, 07:08 PM
Last Post: ndc85430
  Why doesn't this print statement work? stylingpat 10 6,027 Mar-23-2021, 07:54 PM
Last Post: buran
  Two types of single quotes Led_Zeppelin 2 1,988 Mar-15-2021, 07:55 PM
Last Post: BashBedlam
  Print variable values from a list of variables xnightwingx 3 2,721 Sep-01-2020, 02:56 PM
Last Post: deanhystad
  Runs perfect in Python but fails to print last statement when converted to .exe. Help sunil422 3 2,914 Aug-13-2020, 01:22 PM
Last Post: deanhystad
  print function help percentage and slash (multiple variables) leodavinci1990 3 2,566 Aug-10-2020, 02:51 AM
Last Post: bowlofred
  Quotes vs. no quotes around numbers Mark17 6 3,268 Aug-06-2020, 04:13 AM
Last Post: t4keheart
  Create, assign and print variables in loop steven_tr 10 4,516 May-28-2020, 04:26 PM
Last Post: ndc85430
  Taking brackets out of list in print statement pythonprogrammer 3 2,493 Apr-13-2020, 12:25 PM
Last Post: perfringo

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020