- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to iterate by sequence index in Python?
Sequence objects in Python are an ordered collection of items. Each item in the sequence (list, tuple and string) is accessible by index starting with 0.
To traverse elements in a list
>>> L1=[10,20,30,40,50] >>> for i in range(len(L1)): print (L1[i]) 10 20 30 40 50
To slice one character at a time out of a string
>>> string ='TutorialsPoint' >>> for i in range(len(string)): print (string[i]) T u t o r i a l s P o i n t
Advertisements