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.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  How to find the first and last of one of several characters in a list of strings? tadsss 2 381 Jun-02-2020, 05:23 PM
Last Post: bowlofred
  Remove escape characters / Unicode characters from string DreamingInsanity 5 957 May-15-2020, 01:37 PM
Last Post: snippsat
  Escaping '$' in pymongo raulp2301 0 411 Feb-14-2020, 03:48 PM
Last Post: raulp2301
  CSV file escaping characters lokhtar 2 513 Dec-09-2019, 06:48 PM
Last Post: lokhtar
  Split a long string into other strings with no delimiters/characters krewlaz 4 556 Nov-15-2019, 02:48 PM
Last Post: ichabod801
  Finding multiple strings between the two same strings Slither 1 749 Jun-05-2019, 09:02 PM
Last Post: Yoriz
  Slicing Python list of strings into individual characters Drone4four 5 1,102 Apr-17-2019, 07:22 AM
Last Post: perfringo
  For loops, strings and printing words with even characters Drone4four 8 1,422 Oct-05-2018, 09:23 AM
Last Post: volcano63
  Escaping whitespace and parenthesis in filenames jehoshua 2 3,258 Mar-21-2018, 09:12 AM
Last Post: jehoshua
  lists, strings, and byte strings Skaperen 2 1,836 Mar-02-2018, 02:12 AM
Last Post: Skaperen

Forum Jump:

User Panel Messages

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