Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #98907

palindrome

Path csiph.com!xmission!news.glorb.com!peer01.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!post01.iad.highwinds-media.com!fx12.iad.POSTED!not-for-mail
From Seymore4Head <Seymore4Head@Hotmail.invalid>
Newsgroups comp.lang.python
Subject palindrome
Message-ID <s4bl4bd739gfq92c5hipb16grv8a5fh5pb@4ax.com> (permalink)
X-Newsreader Forte Agent 4.2/32.1118
MIME-Version 1.0
Content-Type text/plain; charset=us-ascii
Content-Transfer-Encoding 7bit
Lines 21
X-Complaints-To abuse@blocknews.net
NNTP-Posting-Date Tue, 17 Nov 2015 04:29:31 UTC
Organization blocknews - www.blocknews.net
Date Mon, 16 Nov 2015 23:29:01 -0500
X-Received-Bytes 1000
X-Received-Body-CRC 4150114423
Xref csiph.com comp.lang.python:98907

Show key headers only | View raw


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
    count+=1
    if str1==str1[::-1]:        
        break
    else:
        str1=""
print "Tries= ",count
print str1

Back to comp.lang.python | Previous | NextNext in thread | Find similar | Unroll thread


Thread

palindrome Seymore4Head <Seymore4Head@Hotmail.invalid> - 2015-11-16 23:29 -0500
  Re: palindrome Abhiram R <abhi.darkness@gmail.com> - 2015-11-17 10:09 +0530
    Re: palindrome Seymore4Head <Seymore4Head@Hotmail.invalid> - 2015-11-16 23:48 -0500
      Re: palindrome Abhiram R <abhi.darkness@gmail.com> - 2015-11-17 10:25 +0530
      Re: palindrome Peter Otten <__peter__@web.de> - 2015-11-17 10:48 +0100
  Re: palindrome Peter Otten <__peter__@web.de> - 2015-11-17 10:31 +0100

csiph-web