Abhiram R wrote:
> Haha. Nice. Although with your length of string and the range you're
> picking from,the chances of you getting a palindrome are (1/24!) :D
Are you sure?
>>> candidates = list(itertools.product(string.ascii_lowercase, repeat=4))
>>> le
ring is a
palindrome. With that the loop will become
tries = 0
while True:
tries += 1
candidate = random_string(length=4)
print(candidate)
if is_palindrome(candidate):
break
print(tries, "tries")
2. If you plan to reuse these functions put the above code in a funct
for i in range(letcount):
> >> a=random.choice(abc)
> >> str1+=a
> >> print str1
> >> count+=1
> >> if str1==str1[::-1]:
> >> break
> >> else:
> >> str1=""
> >&
+=1
>> if str1==str1[::-1]:
>> break
>> else:
>> str1=""
>> print "Tries= ",count
>> print str1
>> --
>>
>> ?
>
>The question asks to get an input from the user and print if it's a
>palindrome or not
opqrstuvwxyz'
> while True:
> for i in range(letcount):
> a=random.choice(abc)
> str1+=a
> print str1
> count+=1
> if str1==str1[::-1]:
> break
> else:
> str1=""
> print "Tries= ",count
> p
http://www.practicepython.org/exercise/2014/03/12/06-string-lists.html
Here is my answers. What would make it better?
import random
str1=""
letcount=4
count=0
abc='abcdefghijklmnopqrstuvwxyz'
while True:
for i in range(letcount):
a=random.choice(abc)
str1+=a
print str1
John Ladasky :
> On Monday, June 1, 2015 at 2:22:02 AM UTC-7, Marko Rauhamaa wrote:
>
>> Sota-apina nakataan raastimeen.
>> Apelle pane emit.
>> Saarnaa takanani paatos.
>>
>> (= "The war monkey will be chucked into a grater.
>> Hand the pistils to father-in-law.
>
On Monday, June 1, 2015 at 2:22:02 AM UTC-7, Marko Rauhamaa wrote:
> Sota-apina nakataan raastimeen.
> Apelle pane emit.
> Saarnaa takanani paatos.
>
> (= "The war monkey will be chucked into a grater.
> Hand the pistils to father-in-law.
> Pathos does prea
On 2015-06-02 01:55, fl wrote:
On Sunday, May 31, 2015 at 9:46:56 PM UTC-7, fl wrote:
Hi,
When I search solution of reverse a string/number, I came across a short
function online:
>>> def palindrome(num):
return str(num) == str(num)[::-1]
I thought that it is a general func
On Monday, June 1, 2015 at 5:55:14 PM UTC-7, fl wrote:
> On Sunday, May 31, 2015 at 9:46:56 PM UTC-7, fl wrote:
> > Hi,
> >
> > When I search solution of reverse a string/number, I came across a short
> > function online:
> >
> > >>> def palindrom
On Sunday, May 31, 2015 at 9:46:56 PM UTC-7, fl wrote:
> Hi,
>
> When I search solution of reverse a string/number, I came across a short
> function online:
>
> >>> def palindrome(num):
> return str(num) == str(num)[::-1]
>
> I thought that it is a gene
On Sun, 31 May 2015 21:46:31 -0700, fl wrote:
>>>> def palindrome(num):
Note carefully the spelling(1): palindrome
>>>> parlindrome(a)
Note carefully the spelling(2): parlindrome
> NameError: name 'parlindrome' is not defined
Compare carefully spelli
On 2015-06-01, Gary Herron wrote:
> On 05/31/2015 09:46 PM, fl wrote:
>> Hi,
>>
>> When I search solution of reverse a string/number, I came across a short
>> function online:
>>
>>>>> def palindrome(num):
>> return str(num) == str(nu
2015-06-01 11:21 GMT+02:00 Marko Rauhamaa :
> David Palao :
>
>> Because "palindrome" != "parlindrome"?
>> Have you read the error message? Did you try to understand it?
>
> When you are starting with any new thing, even the simplest problems
> look b
David Palao :
> Because "palindrome" != "parlindrome"?
> Have you read the error message? Did you try to understand it?
When you are starting with any new thing, even the simplest problems
look baffling. Once you have achieved a few successes, such error
messages start
On Mon, Jun 1, 2015 at 7:46 AM, fl wrote:
> Hi,
>
> When I search solution of reverse a string/number, I came across a short
> function online:
>
> >>> def palindrome(num):
> return str(num) == str(num)[::-1]
>
> I thought that it is a general funct
On 05/31/2015 09:46 PM, fl wrote:
Hi,
When I search solution of reverse a string/number, I came across a short
function online:
def palindrome(num):
return str(num) == str(num)[::-1]
I thought that it is a general function. And with the following variable:
a
'1234
Hi,
Because "palindrome" != "parlindrome"?
Have you read the error message? Did you try to understand it?
Best
2015-06-01 6:46 GMT+02:00 fl :
> Hi,
>
> When I search solution of reverse a string/number, I came across a short
> function online:
>
>>>>
On 05/31/2015 09:46 PM, fl wrote:
Hi,
When I search solution of reverse a string/number, I came across a short
function online:
def palindrome(num):
return str(num) == str(num)[::-1]
I thought that it is a general function. And with the following variable:
No, this function is
Hi,
When I search solution of reverse a string/number, I came across a short
function online:
>>> def palindrome(num):
return str(num) == str(num)[::-1]
I thought that it is a general function. And with the following variable:
>>> a
'1234_'
>>
for your function to not just ignore
some inputs, but give some kind of error for the inputs you don't want
to consider.
Let's say you accept simple Unicode strings, you don't want to ignore
white space, an empty string is palindrome, text cases need to be
ignored.
I don't like
> To deal with "real" palindromes such as, "Madam, I'm Adam,"
> you should probably strip all spaces and punctuation:
>
> # untested
> pat = re.compile(r'[a-z]')
> def is_palindrome(s):
> letters = pat.findall(s.lower())
> return letters == reversed(letters)
Using python 2.5 the above
;)
In [29]: s = 'bannab'
In [30]: a = np.frombuffer(s.lower(), dtype='uint8')
In [31]: np.all(a == a[::-1])
Out[31]: True
In [32]: s = 'bannac'
In [33]: a = np.frombuffer(s.lower(), dtype='uint8')
In [34]: np.all(a == a[::-1])
Out[34]: False
--
http://mail.python.org/mailman/listinfo/pytho
In article ,
Dave Angel wrote:
>
>def is_palindrom(s):
>s = s.lower()
>return s == s[::-1]
To deal with "real" palindromes such as, "Madam, I'm Adam," you should
probably strip all spaces and punctuation:
# untested
pat = re.compile(r'[a-z]')
def is_palindrome(s):
letters = pat.find
In article ,
MRAB wrote:
> On 29/08/2010 21:34, Roy Smith wrote:
> > In article<8dunm7fv5...@mid.individual.net>,
> > Gregory Ewing wrote:
> >
> >> Steven D'Aprano wrote:
> >>> I'm not entirely sure what the use-case for swapcase is.
> >>
> >> Obviously it's for correcting things that were
On 29/08/2010 21:34, Roy Smith wrote:
In article<8dunm7fv5...@mid.individual.net>,
Gregory Ewing wrote:
Steven D'Aprano wrote:
I'm not entirely sure what the use-case for swapcase is.
Obviously it's for correcting things that were typed
in with tHE cAPS lOCK kEY oN bY mISTAKE. :-)
So
I have no idea. That's a lower level of programming than I'm used to
dealing with.
Josh
(I also only tried the one value. Had I tried with other strings that
would fail the test, some
functions may have performed better.)
On Aug 29, 2:19 am, Matteo Landi wrote:
> Well, I tried the also the solu
In article <8dunm7fv5...@mid.individual.net>,
Gregory Ewing wrote:
> Steven D'Aprano wrote:
> > I'm not entirely sure what the use-case for swapcase is.
>
> Obviously it's for correcting things that were typed
> in with tHE cAPS lOCK kEY oN bY mISTAKE. :-)
So it would seem (http://bugs.python
On 29 août, 06:39, Gregory Ewing wrote:
> Steven D'Aprano wrote:
> > I'm not entirely sure what the use-case for swapcase is.
>
> Obviously it's for correcting things that were typed
> in with tHE cAPS lOCK kEY oN bY mISTAKE. :-)
>
+1 QOTW !-)
--
http://mail.python.org/mailman/listinfo/python-l
On 27 août, 20:05, Jussi Piitulainen > def
palindromep(s):
> return ( s == "" or
> ( s[0] == s[-1] and
> palindromep(s[1:-1]) ) )
>
I-can-write-lisp-in-any-language-p !-)
--
http://mail.python.org/mailman/listinfo/python-list
On 27 août, 18:20, Mark Lawrence wrote:
> On 27/08/2010 15:43, Bruno Desthuilliers wrote:
>
> > Dave Angel a écrit :
> > (snip)
>
> >> or (untested)
> >> def is_palindrom(s):
> >> s = s.lower()
> >> return s == s[::-1]
>
> > Right, go on, make me feel a bit more stupid :-/
> > Who's next ?
>
> It
I thought they reached you. Here they are again:
def palindrome(str, i=0, j=-1):
try:
if str[i] == str[j]:
return palindrome(str, i + 1, j - 1)
return False
except IndexError:
return True
def palindrome(str, i=0, j=-1):
try
Matteo Landi writes:
> Well, I tried the also the solution posted above (recursive w/o
> slicing and iterative), and I discovered they were the slowest..
>
> is_palindrome_recursive 2.68151649808
> is_palindrome_slice 0.44510699381
> is_palindrome_list 1.93861944217
> is_palindrome_reversed 3.289
Steven D'Aprano wrote:
I'm not entirely sure what the use-case for swapcase is.
Obviously it's for correcting things that were typed
in with tHE cAPS lOCK kEY oN bY mISTAKE. :-)
--
Greg
--
http://mail.python.org/mailman/listinfo/python-list
Well, I tried the also the solution posted above (recursive w/o
slicing and iterative), and I discovered they were the slowest..
is_palindrome_recursive 2.68151649808
is_palindrome_slice 0.44510699381
is_palindrome_list 1.93861944217
is_palindrome_reversed 3.28969831976
is_palindrome_recursive_no_
This whole conversation got interesting, so I thought I'd run some
speed tests:
The code:
from timeit import Timer
def is_palindrome_recursive(s):
if len(s) <= 1:
return True
if s[0] != s[-1]:
return False
else:
return is_palindrome(s[1:-1])
def is_palindrome_
On Sat, 28 Aug 2010 15:11:03 +0300, Jussi Piitulainen wrote:
[...]
> When I said that there could be such a method, I was merely objecting to
> a statement, made in response to me, that there could not be such a
> method because strings are immutable. You clearly agree with me that
> that statemen
s. It would return
the reversed string, like .swapcase() returns the swapcased string.
Could be, but the main use case seems to be for palindrome testing ;-)
Given that slicing and reversed() can do the same thing, the need is
thin.
The need is quite thin, but immutability of strin
On Sat, 28 Aug 2010 09:48:47 +0100
Ian wrote:
> > def palindromep(s):
> > def reversed(s):
> > return s[::-1]
> > return s == reversed(s)
> I like this.
>
> s[::-1] is obscure and non-obvious, especially to Python noobs.
>
> This makes it clear what is going on and why at a co
On Aug 28, 11:55 am, Steven D'Aprano wrote:
> On Sat, 28 Aug 2010 09:22:13 +0300, Jussi Piitulainen wrote:
> > Terry Reedy writes:
> >> On 8/27/2010 3:43 PM, Jussi Piitulainen wrote:
> >> > Dave Angel writes:
[snip]
> Not everything needs to be a built-in method. There is already a standard
> way
Paul Rubin writes:
> Ian writes:
> > On 27/08/2010 21:51, Jussi Piitulainen wrote:
> >> Meanwhile, I have decided to prefer this:
> >>
> >> def palindromep(s):
> >> def reversed(s):
> >> return s[::-1]
> >> return s == reversed(s)
> > I like this.
> > s[::-1] is obscure and non-
e not - and
I am quite aware that Python is not Lisp.
My background is elsewhere, I was not paying particular attention to
the name at all, and I just could not be bothered to look up what
implications any of palindrome, palindromic, ispalindrome,
is_palindrome, isPalindrome, has_palindrome_nature,
strings. It would return
>>> > the reversed string, like .swapcase() returns the swapcased string.
>>>
>>> Could be, but the main use case seems to be for palindrome testing ;-)
>>> Given that slicing and reversed() can do the same thing, the need is
>>&
ersed string, like .swapcase() returns the swapcased string.
>>
>> Could be, but the main use case seems to be for palindrome testing ;-)
>> Given that slicing and reversed() can do the same thing, the need is
>> thin.
>
> The need is quite thin, but immutability of strings
On Sat, 28 Aug 2010 09:48:47 +0100, Ian wrote:
> On 27/08/2010 21:51, Jussi Piitulainen wrote:
>> Meanwhile, I have decided to prefer this:
>>
>> def palindromep(s):
>> def reversed(s):
>> return s[::-1]
>> return s == reversed(s)
> I like this.
It's silly, needlessly complicat
Paul Rubin writes:
> Ian writes:
>> On 27/08/2010 21:51, Jussi Piitulainen wrote:
>>> Meanwhile, I have decided to prefer this:
>>>
>>> def palindromep(s):
>>> def reversed(s):
>>> return s[::-1]
>>> return s == reversed(s)
>> I like this.
>> s[::-1] is obscure and non-obviou
Ian writes:
> On 27/08/2010 21:51, Jussi Piitulainen wrote:
>> Meanwhile, I have decided to prefer this:
>>
>> def palindromep(s):
>> def reversed(s):
>> return s[::-1]
>> return s == reversed(s)
> I like this.
> s[::-1] is obscure and non-obvious, especially to Python noobs.
On 27/08/2010 21:51, Jussi Piitulainen wrote:
Meanwhile, I have decided to prefer this:
def palindromep(s):
def reversed(s):
return s[::-1]
return s == reversed(s)
I like this.
s[::-1] is obscure and non-obvious, especially to Python noobs.
This makes it clear what is goin
ems like a bit of overkill... Why would you want to define a
> function in a function for something trivial like this? Just
>
> def palindrome(s):
> return s[::-1]
>
> will do fine.
I'm sure your version will do something just fine, but what that
something is, I ca
main use case seems to be for palindrome testing ;-)
> Given that slicing and reversed() can do the same thing, the need is thin.
The need is quite thin, but immutability of strings is not an issue,
just like there can be .swapcase() though strings are immutable. That
is all I am saying above.
-
versed would be better called .reversed().
>>
>> Yes, agreed.
>>
>> Meanwhile, I have decided to prefer this:
>>
>> def palindromep(s):
>> def reversed(s):
>> return s[::-1]
>> return s == reversed(s)
>> --
>> http://mail.p
def reversed(s):
> return s[::-1]
> return s == reversed(s)
> --
> http://mail.python.org/mailman/listinfo/python-list
>
That seems like a bit of overkill... Why would you want to define a
function in a function for something trivial like this? Just
def palindrome(s):
return s[::-1]
will do fine.
Of course, you can stick the inner function in a library somewhere if you like.
Regards,
Richard
--
http://mail.python.org/mailman/listinfo/python-list
On 8/27/2010 3:43 PM, Jussi Piitulainen wrote:
Dave Angel writes:
There could easily be a .reverse() method on strings. It would return
the reversed string, like .swapcase() returns the swapcased string.
Could be, but the main use case seems to be for palindrome testing ;-)
Given that
MRAB writes:
> On 27/08/2010 20:43, Jussi Piitulainen wrote:
>> Dave Angel writes:
>>> Jussi Piitulainen wrote:
Agreed. But is there any nicer way to spell .reverse than [::-1]
in Python? There is .swapcase() but no .reverse(), right?
>>> There can't be a .reverse() method on string,
On 27/08/2010 20:43, Jussi Piitulainen wrote:
Dave Angel writes:
Jussi Piitulainen wrote:
Ian writes:
Of course, the simpler way is to use the definition of a
Palindrome as the same backwards and forwards.
def isPalindrome(pal)
return pal == pal.reverse
Agreed. But is there any
Dave Angel writes:
> Jussi Piitulainen wrote:
>> Ian writes:
>>> Of course, the simpler way is to use the definition of a
>>> Palindrome as the same backwards and forwards.
>>>
>>> def isPalindrome(pal)
>>> return pal == pal.reverse
>
On Fri, 27 Aug 2010 12:02:39 -0400
"D'Arcy J.M. Cain" wrote:
> On Fri, 27 Aug 2010 11:49:42 -0400
> "D'Arcy J.M. Cain" wrote:
> > is_palindrome = lambda x: x == x.lower()[::-1]
>
> Oops. Simple and wrong.
>
> is_palindrome = lambda x: x.lower() == x.lower()[::-1]
slightly more efficient I thi
Jussi Piitulainen wrote:
Ian writes:
If you want to or must do it recursively.
(Shown in pseudo code to make the logic clearer)
def isPalindrome(pal)
''' test pal (a list) is a palindrome '''
if length of pal = 1
return True # all one
Ian writes:
> If you want to or must do it recursively.
> (Shown in pseudo code to make the logic clearer)
>
> def isPalindrome(pal)
> ''' test pal (a list) is a palindrome '''
> if length of pal = 1
> return True # all
On 27/08/2010 18:28, Mark Lawrence wrote:
On 27/08/2010 17:53, MRAB wrote:
On 27/08/2010 17:20, Mark Lawrence wrote:
On 27/08/2010 15:43, Bruno Desthuilliers wrote:
Dave Angel a écrit :
(snip)
or (untested)
def is_palindrom(s):
s = s.lower()
return s == s[::-1]
Right, go on, make me feel
On 8/27/2010 4:53 AM, Baba wrote:
level: beginner
the following code looks ok to me but it doesn't work. I would like
some hints as to where my reasoning / thought goes wrong
def i_palindrome(pal):
while len(pal)>1:
if pal[0] == pal[-1]:
pal=pal[1:-1]
return True
print i_palindrome(
On 27/08/2010 17:53, MRAB wrote:
On 27/08/2010 17:20, Mark Lawrence wrote:
On 27/08/2010 15:43, Bruno Desthuilliers wrote:
Dave Angel a écrit :
(snip)
or (untested)
def is_palindrom(s):
s = s.lower()
return s == s[::-1]
Right, go on, make me feel a bit more stupid :-/
Who's next ?
It co
On 27/08/2010 17:20, Mark Lawrence wrote:
On 27/08/2010 15:43, Bruno Desthuilliers wrote:
Dave Angel a écrit :
(snip)
or (untested)
def is_palindrom(s):
s = s.lower()
return s == s[::-1]
Right, go on, make me feel a bit more stupid :-/
Who's next ?
It could be worse, try responding to is
lindrome('annab')
If you want to or must do it recursively.
(Shown in pseudo code to make the logic clearer)
def isPalindrome(pal)
''' test pal (a list) is a palindrome '''
if length of pal = 1
return True # all one letter strings are pal
On 27/08/2010 15:43, Bruno Desthuilliers wrote:
Dave Angel a écrit :
(snip)
or (untested)
def is_palindrom(s):
s = s.lower()
return s == s[::-1]
Right, go on, make me feel a bit more stupid :-/
Who's next ?
It could be worse, try responding to issue 9702. :)
Cheers.
Mark Lawrence.
--
h
On Fri, 27 Aug 2010 11:49:42 -0400
"D'Arcy J.M. Cain" wrote:
> is_palindrome = lambda x: x == x.lower()[::-1]
Oops. Simple and wrong.
is_palindrome = lambda x: x.lower() == x.lower()[::-1]
--
D'Arcy J.M. Cain | Democracy is three wolves
http://www.druid.net/darcy/|
On Fri, 27 Aug 2010 16:43:16 +0200
Bruno Desthuilliers wrote:
> Dave Angel a écrit :
> > def is_palindrom(s):
> >s = s.lower()
> >return s == s[::-1]
>
>
> Right, go on, make me feel a bit more stupid :-/
> Who's next ?
How about a one-liner?
is_palindrome = lambda x: len(x)> 0 and x =
Dave Angel a écrit :
(snip)
or (untested)
def is_palindrom(s):
s = s.lower()
return s == s[::-1]
Right, go on, make me feel a bit more stupid :-/
Who's next ?
--
http://mail.python.org/mailman/listinfo/python-list
A')
So you just have to extract the symetric halves, reverse one, and compare
both (case insensitive compare while we're at it).
Yes, this is a correct observation, but it is not necessary to compare
the halves; Simply compare the complete string with its reverse. If
they match, it is a pali
is > 1
- exiting this loop means all compared chars were identical hence it
is a palindrome and i return True
Your problem is that when first and last char are not equal, you don't
exit the while loop. You need a "return False" somewhere here, ie:
def is_palindrom(pal):
while
> Yes, this is a correct observation, but it is not necessary to compare
> the halves; Simply compare the complete string with its reverse. If
> they match, it is a palindrome.
I've always used to implement the is_palindrome function as you
suggest, i.e. comparing the original s
')
>
> So you just have to extract the symetric halves, reverse one, and compare
> both (case insensitive compare while we're at it).
Yes, this is a correct observation, but it is not necessary to compare
the halves; Simply compare the complete string with its reverse. If
th
means all compared chars were identical hence it
is a palindrome and i return True
Your problem is that when first and last char are not equal, you don't
exit the while loop. You need a "return False" somewhere here, ie:
def is_palindrom(pal):
while len(pal)>1:
# NB : inve
ual continue
> - create a new, shorter string starting at index 1 and ending at
> second last index (up to but not including index-1
> -restart the while loop as long as length of string is > 1
> - exiting this loop means all compared chars were identical hence it
> is a palindrome an
One possible reason I can think of -
"- exiting this loop means all compared chars were identical hence it
is a palindrome and i return True"
is probably incorrect reasoning. Think again.
Also, you may consider posting your code in a way that preserves the
whitespace characters.
Cheer
ting this loop means all compared chars were identical hence it
is a palindrome and i return True
tnx
Baba
--
http://mail.python.org/mailman/listinfo/python-list
Mensanator wrote:
It hasn't. and here's why:
IDLE 2.6b1
seq=['a','n','n','a']
seq.reversed()
Traceback (most recent call last):
File "", line 1, in
seq.reversed()
AttributeError: 'list' object has no attribute 'reversed'
My apologies. reversed() is a builtin func, not a method, a
; >> spam = ['a', 'n', 'n', 'a']
> >> eggs = spam[:]
> >> if spam.reverse() == eggs:
> >> � � print "Palindrome"
>
> > Your explanation is correct, but your example code compares None to
> > ['a
eturn None. Hence, the comparison you are
doing is between the original list and a None, which is False, naturally.
Try this:
spam = ['a', 'n', 'n', 'a']
eggs = spam[:]
if spam.reverse() == eggs:
print "Palindrome"
Your explanation is correct, bu
None. Hence, the comparison you are
doing is between the original list and a None, which is False, naturally.
Try this:
spam = ['a', 'n', 'n', 'a']
eggs = spam[:]
if spam.reverse() == eggs:
print "Palindrome"
Your explanation is correct, bu
None. Hence, the comparison you are
> doing is between the original list and a None, which is False, naturally.
> Try this:
>
> spam = ['a', 'n', 'n', 'a']
> eggs = spam[:]
> if spam.reverse() == eggs:
> print "Palindrome"
On Jul 11, 6:20 pm, Mensanator <[EMAIL PROTECTED]> wrote:
> > Try this:
>
> > spam = ['a', 'n', 'n', 'a']
> > eggs = spam[:]
> > if spam.reverse() == eggs:
> > print "Palindrome"
>
>
omparison you are doing
> is between the original list and a None, which is False, naturally.
> Try this:
>
> spam = ['a', 'n', 'n', 'a']
> eggs = spam[:]
> if spam.reverse() == eggs:
> print "Palindrome"
>
>
Um, wouldn
st which
> called it. It does not return a /new/ list which is a reversed version
> of the original, as you expected it to. Since it doesn't return anything
> explicitly, Python makes it return None. Hence, the comparison you are
> doing is between the original list and a None, which i
Denis Kasak:
> spam = ['a', 'n', 'n', 'a']
> eggs = spam[:]
> if spam.reverse() == eggs:
> print "Palindrome"
An alternative version:
>>> txt = "anna"
>>> txt == txt[::-1]
True
>>> txt = "
st which
> called it. It does not return a /new/ list which is a reversed version
> of the original, as you expected it to. Since it doesn't return anything
> explicitly, Python makes it return None. Hence, the comparison you are
> doing is between the original list and a None, which
nything
explicitly, Python makes it return None. Hence, the comparison you are
doing is between the original list and a None, which is False, naturally.
Try this:
spam = ['a', 'n', 'n', 'a']
eggs = spam[:]
if spam.reverse() == eggs:
print &quo
Hi all,
Can someone please explain to me why the following evaluates as false?
>>>list=['a','n','n','a']
>>>list==list.reverse()
>>>False
I'm stumped :s
--
http://mail.python.org/mailman/listinfo/python-list
Here is some semi-obfuscated Python, to generate rotational
palindromes:
from random import choice
base = "sznuoxpqbdMWOINZXSH"
rot = dict(zip(base,"szunoxdbqpWMOINZXSH"))
for i in range(40):
s1 = [choice(base) for j in range(choice((2,3,4)))]
start = (1,2)[rot[s1[-1]]==s1[-1] and choice
89 matches
Mail list logo