【问题标题】:How can I increase index i in range python in if-clause? [duplicate]如何在 if 子句中增加范围 python 中的索引 i? [复制]
【发布时间】:2019-04-29 11:02:16
【问题描述】:
a = "a4b4t8a3a3w2q5a8o9i8"
for i in range(0, len(a)):
  if a[i].isdigit() is False:
    print("detected letter")
    i +=5 #this does not increase the i by 5 each tiem I find a letter

这无助于索引“i”向前跳 5。为什么?

【问题讨论】:

标签: python


【解决方案1】:

试试这个

a[i + 5]

而不是

i + 5

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-02-18
    • 2012-07-28
    • 1970-01-01
    相关资源
    最近更新 更多