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.
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}")
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))
Print has to be called as print("Hello World!")
instead of as print = "Hello World"
to properly function.
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
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.
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}")
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))
Print has to be called as print("Hello World!")
instead of as print = "Hello World"
to properly function.
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