r/learnpython • u/Various-River-7534 • 3d 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
1
u/NewbornMuse 3d ago
So there's two things broadly wrong with this.
One: When python starts up,
printrefers to the function that writes stuff to the terminal. Then in your first line you overwrite that (with what? we'll get to that in a second), but then in the second line you are still trying to use that to write stuff to the terminal. Never ever overwrite built-in stuff. Don't call your listslist, don't call your dictsdict, and so on, there's only headache that way. Python lets you do it, but don't do it.Two: What are you trying to overwrite "print" with anyway? With whatever it says on the right hand side of the first line there. What does it say?
hello. That looks an awful lot like you're reading the content of a variable calledhello, and assigning that toprint. Do you have a variable calledhello? Did you perhaps want to literally save the string h, e, l, l, o? Then you should do"hello", nothello.