Tuesday, June 29, 2021

Python Program to Print String

 

Print String in Python

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.

Python Programming Code to Print String

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);

No comments:

Post a Comment

Ads