enumerate.py 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. a = [10, 20, 30, 40, 50]
  2. s = 'hello'
  3. t = ('apple', 'banana', 'mango')
  4. d = {'a': 1, 'b': 2, 'c': 3}
  5. # for index, value in enumerate(a):
  6. # print(index, value)
  7. # for index, value in enumerate(a, 1):
  8. # print(index, value)
  9. # оно же с параметром start
  10. # for index, value in enumerate(a, 1):
  11. # print(index, value)
  12. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  13. # words = ['feel', 'graduate', 'movie', 'fashionable', 'bacon',
  14. # 'drop', 'produce', 'acquisition', 'cheap', 'strength',
  15. # 'master', 'perception', 'noise', 'strange', 'am']
  16. # words_with_position = list()
  17. # for index, value in enumerate(words, start=1):
  18. # words_with_position.append((value, index))
  19. # print(words_with_position)
  20. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  21. # english_words = ('attack', 'bless', 'look', 'reckless', 'short', 'monster', 'trolley', 'sound',
  22. # 'ambiguity', 'researcher', 'trunk', 'coat', 'quantity', 'question', 'tenant',
  23. # 'miner', 'definite', 'kit', 'spectrum', 'satisfied', 'selection', 'carve',
  24. # 'ask', 'go', 'suggest')
  25. # for index, value in enumerate(english_words, start=1):
  26. # print(f'Word № {index} = {value}')
  27. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  28. # num = list(input())
  29. # num.reverse()
  30. # new_list = [int(value)*2 if index%2 == 0 else int(value) for index, value in enumerate(num, start=1)]
  31. # for i in range(len(new_list)):
  32. # if new_list[i] > 9:
  33. # new_list[i] -= 9
  34. # if sum(new_list)%10 == 0:
  35. # print('True')
  36. # else:
  37. # print('False')
  38. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~