+ 3

Difference between input and raw input in python

9th Aug 2020, 7:44 AM
Tayyib
Tayyib - avatar
2 Answers
+ 5
raw_input() – It reads the input or command and returns a string. input() – Reads the input and returns a python type like list, tuple, int, etc. for more info visit👇 https://www.geeksforgeeks.org/difference-between-input-and-raw_input-functions-in-python/
9th Aug 2020, 7:47 AM
Arsenic
Arsenic - avatar
+ 2
Regardless of input of string or raw string, we can create raw string explicitely. this is a regular string in python 3.x: txt = 'to get a new line in string output, we can include a \n to achieve this' if we print txt, output is (\n is interpreted as new line) : to get a new line in string output, we can include a to achieve this to print the text as it was created, we can use a raw string by using 'r' like: txt1 = r'to get a new line in string output, we can include a \n to achieve this' the output of txt1 is now: to get a new line in string output, we can include a \n to achieve this
9th Aug 2020, 1:31 PM
Lothar
Lothar - avatar