A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2012-June/120024.html below:

[Python-Dev] next alpha sequence value from var pointing to array

[Python-Dev] next alpha sequence value from var pointing to array [Python-Dev] next alpha sequence value from var pointing to arrayjdmorgan jdmorgan at unca.edu
Thu Jun 7 04:32:09 CEST 2012
Hello,

I am hoping that this list is a good place to ask this question.I am 
still fairly new to python, but find it to be a great scripting 
language.Here is my issue:

I am attempting to utilize a function to receive any sequence of letter 
characters and return to me the next value in alphabetic order e.g. send 
in "abc" get back "abd".I found a function on StackExchange (Rosenfield, 
A 1995) that seems to work well enough (I think):

def next(s):

strip_zs = s.rstrip('z')

if strip_zs:

return strip_zs[:-1] + chr(ord(strip_zs[-1]) + 1) + 'a' * (len(s) - 
len(strip_zs))

else:

return 'a' * (len(s) + 1)

I have found this function works well if I call it directly with a 
string enclosed in quotes:

returnValue = next("abc")

However, if I call the function with a variable populated from a value I 
obtain from an array[] it fails returning only ^K

Unfortunately, because I don't fully understand this next function I 
can't really interpret the error.Any help would be greatly appreciated.

Thanks ahead of time,

Derek

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20120606/21d28dff/attachment-0001.html>
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4