To print string in python, you have to ask from user to enter a string and print it back on the output screen using the print() statement as shown in the program given below.
Following python program ask from the user to enter the string to print that string as output of the program:
# Python Program - Print String print("Enter 'x' for exit."); string = input("Enter string: "); if string == 'x': exit(); else: print("\nYou entered:",string);
Here is the sample run of the above python program to illustrates how to print string:
Now enter any string say i love to program on codescracker and press enter key to see what was the string that you have entered in this program as shown here:
Here is the same program on python shell:
You may also like to learn or practice the same program in other popular programming languages: