본문 바로가기
Programming/Python

[Python] TypeError: unsupported operand type(s) for |: 'type' and 'type'

by 빅경 2024. 6. 19.
728x90
반응형

Error Message

 TypeError: unsupported operand type(s) for |: 'type' and 'type'

 

Error Cause  
'type' and 'type' syntax is only supported in 3.10 or later. Use
 

Example

 ## Error Code
 def debug(msg: str | list):
     print(msg)
 
 ## Right Code
 def debug(msg: [str, list]):
     print(msg)
 
 debug("text")
728x90
반응형