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

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

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

MS Excel to WhatsApp Bulk Message in single Click

Excel to WhatsApp Bulk Message VBA Code File Download VBA Note Pad File - Click here Download Excel Practice File - Click here Copy Code her...

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