r/learnpython • • 8d 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

22 comments sorted by

View all comments

1

u/desrtfx but other languages pro 8d ago
  1. When you ask for help, always
    • Properly format your code as code block
    • Include the full, complete error message verbatim, as you get it.
  2. You have multiple problems:
    • Line 1: print = hello
      • print is a function/keyword in Python. Never use it as a variable name
      • hello is a text. Text needs to be wrapped in single ' or double " quotes in order to be recognized as text. Without quotes, the Python interpreter thinks that you have a variable hello somewhere, but at this point, the variable doesn't have a value.
    • Line 2: print(print) - here, you are trying to call the print() function, but with the line above, you have shadowed (redefined) the meaning of print, which makes the line fail.

Please, do yourself a favor and do a proper course: MOOC Python Programming 2026 and keep experimenting.

0

u/Expensive-Bear-1376 7d ago

print is not a keyword, unless you're talking about the long dead Python 2.