fork download
  1. # your code goes here
  2. #hero inventory tuple
  3. #create tuple
  4. #print tuple
  5. #count tuple length
  6. #if in tuple prit smth
  7. #check position of item by indexing it
  8. #summon item by its position and print
  9. #print part-slice of tuple by two defined positions
  10. #concantenate 2 tuples
  11. inventory = ('armor',
  12. 'rental shield',
  13. 'sword', 'sword1', 'sword2', 'sword3')
  14. print inventory
  15. inv1 = ('sword4', 'sword5')
  16. if inv1 not in inventory:
  17. inventory += inv1
  18. len1 = len(inventory)
  19. len2 = -len(inventory)
  20. print len1
  21. print inventory[len2:len1]
  22. print 'So you have', len1, 'items in your inventory'
  23. print 'If you want to summon an item enter its appropriate number between', len1, 'and', len2
  24. enter1 = int(raw_input('Enter your number here'))
  25. if enter1 >= len2 and enter1 <= len1:
  26. print inventory[enter1]
  27. if enter1 == 3:
  28. print inventory[0:3]
  29. raw_input('\n\nP')
Runtime error #stdin #stdout #stderr 0.01s 7696KB
stdin
Standard input is empty
stdout
('armor', 'rental shield', 'sword', 'sword1', 'sword2', 'sword3')
8
('armor', 'rental shield', 'sword', 'sword1', 'sword2', 'sword3', 'sword4', 'sword5')
So you have 8 items in your inventory
If you want to summon an item enter its appropriate number between 8 and -8
Enter your number here
stderr
Traceback (most recent call last):
  File "prog.py", line 24, in <module>
EOFError: EOF when reading a line