How do i print out a literal character in python?



  • Some characters have to be what's called escaped meaning a special character put in front of it to prevent the python interpreter from interpreting it as special character.

    This is done using the backslash "" and single quotes or double quotes.

    Using backslash and single quotes.

    print('There\'s ants in my pants')
    

    or

    Using doubles quotes. Easier to read.

    print("There's ants in my pants")
    

Log in to reply
 

© Lightnetics 2024