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>>

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

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

Excel to WhatsApp automation

Send Whatsapp Custom Message Using MS Excel | Excel to Whatsapp Step-by-Step Guide Download Practice file -  Click Here The Secret Behind Wh...

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