ไม่ได้ คุณไม่สามารถแก้ไข range ได้หลังจากสร้างแล้ว แต่สิ่งที่ทำได้คือใช้ while loop แทน ตัวอย่างเช่น หากมีโค้ดแบบนี้:
for i in range(lower_limit, higher_limit, step_size):
# some code
if i == 10:
higher_limit = higher_limit + 5
สามารถเปลี่ยนเป็น:
i = lower_limit
while i < higher_limit:
# some code
if i == 10:
higher_limit = higher_limit + 5
i += step_size