Checking if a string's characters are ascending alphabetically and its ascent is evenly spaced python

前端 未结 4 1824
名媛妹妹
名媛妹妹 2020-12-12 01:09

So need to check if a string\'s characters are ascending alphabetically and if that ascent is evenly spaced.

a = \"abc\"
b = \"ceg\"

So a i

4条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-12 01:32

    only hints for home work,,,

    you can try to make use of something from this

    In [100]: z = 'abc'
    In [101]: [ord(x) for x in z]
    Out[101]: [97, 98, 99]
    

    then there can be several logics to check if the elements are evenly spaced :)

提交回复
热议问题