Position of Difference X28758


Statement
 

pdf   zip

thehtml

Design a function @pos_dif(r, s)@ that, given two strings r and s, returns the first position at which r and s are different. If r and s are equal, the function must return −1.

Sample session
>>> pos_dif('pero', 'peros')
4
>>> pos_dif('alaska', 'alaska')
-1
>>> pos_dif('caramba', 'calabaza')
2
>>> pos_dif('alas', 'ala')
3
Information
Author
InfBesos
Language
English
Translator
Original language
Catalan
Other languages
Catalan Spanish
Official solutions
Python
User solutions
Python