Advertisement
makispaiktis

Python5 - Lists

Apr 6th, 2019 (edited)
303
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.52 KB | None | 0 0
  1. friends = ["Kevin", "Karen", "Jim"];
  2. print(friends);
  3. print(friends[0]);
  4. print(friends[1]);
  5. print(friends[2]);
  6. print("\n");
  7. index = input("Enter a number: ");
  8. print("Friend in index " + str(index) + " is " + friends[int(index) % 3]);
  9. print("\n");
  10. newFriends = ["Friend0", "Friend1", "Friend2", "Friend3", "Friend4"];
  11. print(newFriends);
  12. print(newFriends[1:]);
  13. print(newFriends[2:]);
  14. print(newFriends[0:2]);
  15. print("\n");
  16. newList = newFriends[2:]
  17. print(newList);
  18. print("\n");
  19. newFriends[0] = "Friend10";
  20. print(newFriends);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement