Showing posts with label python trivia. Show all posts
Showing posts with label python trivia. Show all posts

Friday, January 11, 2019

Python Trivia Post: Raw Strings

We generally know that to print a string in python we need to write simply -

print (" You are my sunshine , if you are here , then I am fine !")

But to print a new line we need to write something like this - 

print (" You are my sunshine ,\n if you are here ,\n then I am fine !")

But sometimes we need the raw string, I don't know when but a hacker friend of mine told me it helps while hacking as it is related to raw string searching. To print a raw string write -

print ( r"You are my sunshine ,\n if you are here ,\n then I am fine !") 

and it will print this - 

"You are my sunshine ,\n if you are here ,\n then I am fine !"

Nice one!!!


Feautured Post

Python Trivia Post: enumerate()

Python has a very useful inbuilt function, which is called enumerate(). This is needed whenever you need the numbering of a certain element...