For loop with String




For loop with String

Example

Looping Through a String

Even strings are iterrable objects, they contain a sequence of characters:

Example

Loop through the letters in the word "banana":

for x in "banana":
  
print(x)

Print each fruit in a fruit list:

fruits = ["apple""banana""cherry"]
for x in fruits:
  
print(x)

The for loop does not require an indexing variable to set beforehand.


<<Previous                                                  Next>>

कोई टिप्पणी नहीं

टिप्पणी: केवल इस ब्लॉग का सदस्य टिप्पणी भेज सकता है.

Send Multiple Emails From Excel | Send Bulk Mail from Excel Sheet with Attachment in One Click

Send Multiple Emails From Excel | Send Bulk Mail from Excel Sheet with Attachment in One Click Download VBA Code Notepad file - Click here D...

Blogger द्वारा संचालित.