Python Forum
Introduction to escaping characters in strings
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Introduction to escaping characters in strings
#1
Hey, brand new to coding so please help out with the fundamental.

I am trying to fix this up, please show me what I am supposed to do

print('I/m learning Python!')
print("A number enclosed in double quotes: "42"")

What is it I need to change??

Thanks!
Reply
#2
First and foremost please put your code in tags.
print('I/m learning Python!')
print("A number enclosed in double quotes: "42"")
Then provide what you have already tried so you can be pointed in the direction that would best help you learn and understand.
Also, be clear about your query... what is it you are trying to do and how are you going about it.

Regarding the printing of the two lines you need to learn the point of quotations when printing a string.
If you are trying to show a piece of the string in quotes you need to change the initial quotation marks used to single ' instead of " so they do not conflict.
print('A number enclosed in double quotes: "42"')
And the first string:
print("I'm learning Python!")
When writing code I personally use single quotes for most things and double quotations when needed in a string or other function.
"Often stumped... But never defeated."
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Trying to understand strings and lists of strings Konstantin23 2 696 Aug-06-2023, 11:42 AM
Last Post: deanhystad
  Splitting strings in list of strings jesse68 3 1,702 Mar-02-2022, 05:15 PM
Last Post: DeaD_EyE
  How to find the first and last of one of several characters in a list of strings? tadsss 2 2,140 Jun-02-2020, 05:23 PM
Last Post: bowlofred
  Remove escape characters / Unicode characters from string DreamingInsanity 5 13,419 May-15-2020, 01:37 PM
Last Post: snippsat
  Escaping '$' in pymongo raulp2301 0 1,608 Feb-14-2020, 03:48 PM
Last Post: raulp2301
  CSV file escaping characters lokhtar 2 2,627 Dec-09-2019, 06:48 PM
Last Post: lokhtar
  Split a long string into other strings with no delimiters/characters krewlaz 4 2,703 Nov-15-2019, 02:48 PM
Last Post: ichabod801
  Finding multiple strings between the two same strings Slither 1 2,478 Jun-05-2019, 09:02 PM
Last Post: Yoriz
  Slicing Python list of strings into individual characters Drone4four 5 3,422 Apr-17-2019, 07:22 AM
Last Post: perfringo
  For loops, strings and printing words with even characters Drone4four 8 5,022 Oct-05-2018, 09:23 AM
Last Post: volcano63

Forum Jump:

User Panel Messages

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