10 个有趣的Python酷招
在 python 中,我们可以返回多个值-
-
A very unique feature of Python is that it returns multiple values at a time.
```py def GFG(): g = 1 f = 2 return g, f
x, y = GFG() print(x, y) ```
Output:
```py (1, 2)
```
-
Allow negative indexing: Python allows negative indexing of its sequence. Index -1 refers to the last element, -2 seconds refers to the last element and so on.
py my_list = ['geeks', 'practice', 'contribute'] print(my_list[-1])
Output:
contribute
版权属于:月萌API www.moonapi.com,转载请注明出处