/
Strings in Python String Traversal Strings in Python String Traversal

Strings in Python String Traversal - PowerPoint Presentation

olivia-moreira
olivia-moreira . @olivia-moreira
Follow
390 views
Uploaded On 2018-02-26

Strings in Python String Traversal - PPT Presentation

Traversing a string Traversing just means to process every character in a string usually from left end to right end Python allows for 2 ways to do this both useful but not identical if all you need is the value of each character in the string ID: 637290

character string traversing python string character python traversing stringvar characters left

Share:

Link:

Embed:

Download Presentation from below link

Download Presentation The PPT/PDF document "Strings in Python String Traversal" is the property of its rightful owner. Permission is granted to download and print the materials on this web site for personal, non-commercial use only, and to display it on your personal computer provided you do not modify the materials and that you retain all copyright notices contained in the materials. By downloading content from our website, you accept the terms of this agreement.


Presentation Transcript

Slide1

Strings in Python

String TraversalSlide2

Traversing a string

Traversing just means to process every character in a string, usually from left end to right end

Python allows for 2 ways to do this – both useful but not identical

if all you need is the value of each character in the string

for

ch

in

stringvar

:

will work fine.

ch

is given the value of each character from left to right, and can be used

in the for loop as you need

The other way uses the

location

of the characters in the string

for

ct

in range(len(

stringvar

)):

makes the variable

ct

an integer which has all the values of the subscripts of the

characters in the string. If it is important that you know

where

a character is, this

is the form you use.