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


Groups > comp.lang.python > #60968

Re: The input and output is as wanted, but why error?

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.fsmpi.rwth-aachen.de!weretis.net!feeder4.news.weretis.net!rt.uk.eu.org!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.001
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'subject:error': 0.03; 'else:': 0.03; 'character,': 0.09; 'len(x)': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'strings.': 0.09; '"word"': 0.16; 'false:': 0.16; 'integer,': 0.16; 'integer.': 0.16; 'message-id:@4ax.com': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'index': 0.16; 'print': 0.22; "aren't": 0.24; 'url:home': 0.24; 'header:X-Complaints-To:1': 0.27; 'dec': 0.30; 'something': 0.35; 'convert': 0.35; 'there': 0.35; 'really': 0.36; 'charset:us- ascii': 0.36; 'subject:?': 0.36; 'turn': 0.37; 'list': 0.37; 'received:76': 0.38; 'needed': 0.38; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'simple': 0.61; 'first': 0.61; 'email addr:gmail.com': 0.63; 'subject:The': 0.64; '2013': 0.98
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Dennis Lee Bieber <wlfraed@ix.netcom.com>
Subject Re: The input and output is as wanted, but why error?
Date Tue, 03 Dec 2013 17:54:41 -0500
Organization IISS Elusive Unicorn
References <387f5b5f-faf1-4715-8d49-e366be53fd00@googlegroups.com> <02798e66-515f-45d8-9f45-92f58b16642d@googlegroups.com>
Mime-Version 1.0
Content-Type text/plain; charset=us-ascii
Content-Transfer-Encoding 7bit
X-Gmane-NNTP-Posting-Host adsl-76-249-27-178.dsl.klmzmi.sbcglobal.net
X-Newsreader Forte Agent 6.00/32.1186
X-No-Archive YES
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.3535.1386111296.18130.python-list@python.org> (permalink)
Lines 34
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1386111297 news.xs4all.nl 2908 [2001:888:2000:d::a6]:53344
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:60968

Show key headers only | View raw


On Tue, 3 Dec 2013 08:35:20 -0800 (PST), geezle86@gmail.com declaimed the
following:

>> x = input() 
>> 
>> if x.isdigit() == False: 
>>     i = len(x) 
>>     j = i - 1 
>>     k = i - 2 
>> 
>>     xList = list(x) 
>> 
>>     if len(xList) > 4: 
>>         print(xList[0], int(k), xList[j], sep='', end='') 

	First off -- there is no need to turn the "word" into a list of
characters... You can index strings. x[0] is the first character, x[-1] is
the last.

	Second... k is already an integer, so there is no need to convert it
into an integer.

	Third... i, j, k aren't really needed -- for something this simple

	if not x.isdigit() and len(x) > 4:
		print ("%s%s%s" % (x[0], len(x)-2, x[-1])
	else:
		print (x)


-- 
	Wulfraed                 Dennis Lee Bieber         AF6VN
    wlfraed@ix.netcom.com    HTTP://wlfraed.home.netcom.com/

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


Thread

The input and output is as wanted, but why error? geezle86@gmail.com - 2013-12-03 07:48 -0800
  Re: The input and output is as wanted, but why error? John Gordon <gordon@panix.com> - 2013-12-03 16:03 +0000
  Re: The input and output is as wanted, but why error? Neil Cerutti <neilc@norwich.edu> - 2013-12-03 16:10 +0000
  Re: The input and output is as wanted, but why error? geezle86@gmail.com - 2013-12-03 08:35 -0800
    Re: The input and output is as wanted, but why error? Dave Angel <davea@davea.name> - 2013-12-03 12:58 -0500
    Re: The input and output is as wanted, but why error? Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2013-12-03 17:54 -0500
  Re: The input and output is as wanted, but why error? geezle86@gmail.com - 2013-12-03 08:36 -0800
    Re: The input and output is as wanted, but why error? Neil Cerutti <neilc@norwich.edu> - 2013-12-03 16:58 +0000
  Re: The input and output is as wanted, but why error? geezle86@gmail.com - 2013-12-03 08:38 -0800
    Re: The input and output is as wanted, but why error? Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-12-03 16:51 +0000
  Re: The input and output is as wanted, but why error? rusi <rustompmody@gmail.com> - 2013-12-03 09:19 -0800
  Re: The input and output is as wanted, but why error? Denis McMahon <denismfmcmahon@gmail.com> - 2013-12-03 23:52 +0000

csiph-web