Presentation is loading. Please wait.

Presentation is loading. Please wait.

Comparing Strings – How to

Similar presentations


Presentation on theme: "Comparing Strings – How to"— Presentation transcript:

1 Comparing Strings – How to
Decisions in Python Comparing Strings – How to

2 How to compare strings Start with the first (leftmost) characters in the two strings While they are the same and strings have not run out, move to the next characters to the right in each string If both strings ran out at the same time, they are equal Otherwise if one string is shorter than the other (only one ran out) and they are identical up to the length of the shorter, the shorter string is the lesser string Otherwise the characters are different, decide based on their ASCII codes – doesn’t matter what the rest of the strings are, this difference is the deciding point


Download ppt "Comparing Strings – How to"

Similar presentations


Ads by Google