Why doesn't Python print return values?

后端 未结 4 1789
一个人的身影
一个人的身影 2021-01-22 00:49

I\'m taking a class in Algorithms and Data Structures (Python). In the book there is an example of a \"stack\" with methods that return certain values. In the book, these values

4条回答
  •  迷失自我
    2021-01-22 01:17

    You can either

    s=Stack()
    s.push(5)
    print s.size()
    print s.isEmpty()
    print s.peek()
    

    or replace your return statements with print.

提交回复
热议问题