print function not showing any output

Question:

Am working on an assignment and encounter this error when i run the print() function, no output was shown.

Below are the code

original_salary = 4050
current_salary = 5000

salary_increase = (current_salary-original_salary) / original_salary 

print = ("The overall salary increase is: " + str(salary_increase)) 

Expecting the output to show "The overall salary increase is: 0.2345679012345679" but no output was shown.

Asked By: Brandon Chan

||

Answers:

print() is a function but you use it as a variable with the assignment. Ensure you don’t assign anything to print so that line should just read:

print("The overall salary increase is: " + str(salary_increase))

or even better use a f-string:

print(f"The overall salary increase is: {salary_increase}")
Answered By: Allan Wind

Your print statement is wrong, just replace this line

print = ("The overall salary increase is: " + str(salary_increase)) 

to this

print("The overall salary increase is: ", str(salary_increase))
Answered By: Qaisar Shabbir

Print has to be called as print("Hello World!") instead of as print = "Hello World" to properly function.

Answered By: Alexander Soiefer

use print("The overall salary increase is: " + str(salary_increase))
instead of assigning it to a variable
Also print is a keyword u can’t use as a variable anyway

Answered By: Keshav
Categories: questions Tags:
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.