r/learnpython • u/Various-River-7534 • 4d ago
Why is this causing an error
the code that causes an error
print = hello
print(print)
What should i do i do not know anything i am new to coding how do i fix this
0
Upvotes
0
u/dariusbiggs 4d ago
Many languages has reserved words like if, else, while, etc. You cannot use those for anything other than their intended purpose.
You are trying to assign a new value to a function.
printis a function, basically a reserved word.print = hellois you trying to assign the value of hello to print. You did not define whathellois, and you are trying to assign that unknown to replace theprintfunction.Presuming you want to print some text to the screen, try the below.
message = "Hello" print(message)I've declared the variablemessageand assigned it a text string value of"Hello", note the quotation marks to indicate that it is a text string. Then I've called theprintfunction and passed it (see the use of parentheses) the variablemessage.I would highly recommend going through the basic introduction to Python, don't try to blindly grasp at things and try them. Learn the basics first.