
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Change Python For Loop Range Higher Limit at Runtime
No, You can't modify a range once it is created. Instead what you can do is use a while loop instead. For example, if you have some code like:
for i in range(lower_limit, higher_limit, step_size):
# some code if i == 10: higher_limit = higher_limit + 5
You can change it to:
i = lower_limit while i < higher_limit: # some code if i == 10: higher_limit = higher_limit + 5 i += step_size
Advertisements