Home  >  Q&A  >  body text

python - How to directly assign specified elements when debugging code in Pycharm for list traversal

Use Pycharm IDE to debug python code. The code error occurs when running to the last element of a list, so I want to directly debug the last element of the list to see where there is a problem.

Use for...in...loop to traverse in a list: [1,3,5,7,9]

list = [1, 3, 5, 7, 9]
for each_item in list:
    print(each_item)

Can we directly skip the previous each_item and directly assign it to 9 when running to the first line of the loop body?
How to operate? Thanks!

淡淡烟草味淡淡烟草味2633 days ago1226

reply all(1)I'll reply

  • 欧阳克

    欧阳克2017-07-05 10:36:14

    list = [9]

    reply
    0
  • Cancelreply