How to Use Echo in Python

By Matt Fregoe

Unlike PHP, the Python programming language does not have an "echo" function that produces a string of output information. Instead, Python uses another similar statement called "print" to produce the same effect. The Python print function evaluates each entered string expression in turn and relays it in simplified form. If the entered information contained within the print expression is not considered a string, it converts automatically to a string before output.

Step 1

Open a python evaluator or code editor.

Step 2

Create a variable with which to define your string --- for example, x = 'Hello' where "x" is the variable and "Hello" is your string. String values include items such as text, numerical content and expressions.

Step 3

Type the word "print" with a trailing left parenthesis after creating the variable.

Step 4

Type the variable you created after the starting parenthesis.

Step 5

Close the print function with a right parenthesis. You should have something like print(x) with "x" representing your variable.

Step 6

Enter this print function; the string you entered to represent the variable should be the output return you receive.

Tips & Warnings

  • If you are using a CGI based output from your Python code, the print function works almost exactly like the PHP echo function. You do not have to define a variable for each string input in this scenario.