1 / 2

Strings in Python

Strings in Python. String Traversal. 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

keziah
Download Presentation

Strings in Python

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Strings in Python String Traversal

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

More Related