Advertisement
user_137

Untitled

Aug 25th, 2018
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.41 KB | None | 0 0
  1. >>> l = [5,2,3,3,4,1,1,-1,1023]
  2.  
  3. >>> for i in l:
  4. ...     print(i, end = ' ')
  5. ... print()
  6. 5 2 3 3 4 1 1 -1 1023
  7.  
  8. >>> l = []  # list is empty
  9.  
  10. >>> for i in l:
  11. ...     print(i, end = ' ')
  12. ... print()
  13.  
  14.  
  15. >>> bool(l)
  16. False
  17.  
  18. >>> bool(l[0])  # now try to test the value of the first
  19. Traceback (most recent call last):
  20.   File "<stdin>", line 1, in <module>
  21. IndexError: list index out of range
  22. list index out of range
  23.  
  24. >>>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement