function is not defined error in Python

后端 未结 5 1898
走了就别回头了
走了就别回头了 2020-11-30 10:38

I am trying to define a basic function in python but I always get the following error when I run a simple test program;

>>> pyth_test(1, 2)

Traceba         


        
5条回答
  •  孤街浪徒
    2020-11-30 11:31

    It works for me:

    >>> def pyth_test (x1, x2):
    ...     print x1 + x2
    ...
    >>> pyth_test(1,2)
    3
    

    Make sure you define the function before you call it.

提交回复
热议问题