Rocksolid Light

News from da outaworlds

mail  files  register  groups  login

Message-ID:  

BOFH excuse #354: Chewing gum on /dev/sd3c


comp / comp.lang.python / Re: Flubbed it in the second interation through the string: range error... HOW?

SubjectAuthor
* Flubbed it in the second interation through the string: range error... HOW?Kevin M. Wilson
`- Re: Flubbed it in the second interation through the string: range error... HOW?Stefan Ram

1
Subject: Flubbed it in the second interation through the string: range error... HOW?
From: Kevin M. Wilson
Newsgroups: comp.lang.python
Date: Wed, 29 May 2024 04:33 UTC
References: 1 2
Path: eternal-september.org!news.eternal-september.org!feeder3.eternal-september.org!fu-berlin.de!uni-berlin.de!not-for-mail
From: kevinmwilson1956@yahoo.com (Kevin M. Wilson)
Newsgroups: comp.lang.python
Subject: Flubbed it in the second interation through the string: range
error... HOW?
Date: Wed, 29 May 2024 04:33:23 +0000 (UTC)
Lines: 50
Message-ID: <mailman.52.1716957209.2909.python-list@python.org>
References: <1901134155.5453771.1716957203090.ref@mail.yahoo.com>
<1901134155.5453771.1716957203090@mail.yahoo.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
X-Trace: news.uni-berlin.de QTTDkmJhN/HGbYRU9p/UeQWgGSjl8PqD/DLeiFbn61SA==
Cancel-Lock: sha1:4go7zEVl5JLFl5TPJBZMRp2oUKI= sha256:A5kBw07wF+7v4ijdhKaM2FK7s4C21GvsNB9UXRi8r8w=
Return-Path: <kevinmwilson1956@yahoo.com>
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=pass
reason="2048-bit key; unprotected key"
header.d=yahoo.com header.i=@yahoo.com header.b=i8nCTVhr;
dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.005
X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'message:': 0.03; 'def':
0.04; 'traceback': 0.04; '(most': 0.05; 'string': 0.07; 'elif':
0.09; 'string,': 0.09; '&gt;': 0.14; '&lt;': 0.16; '---&gt;':
0.16; 'lowercase': 0.16; 'subject:second': 0.16; 'subject:string':
0.16; 'to:addr:python-list': 0.20; 'to:name:python-
list@python.org': 0.24; 'skip:{ 20': 0.26; 'error': 0.29;
'letter,': 0.32; "i'm": 0.33; 'following': 0.35; 'received:66':
0.35; 'cell': 0.36; '8bit%:14': 0.38; 'received:66.163': 0.39;
'received:consmr.mail.ne1.yahoo.com': 0.39; 'block': 0.39;
'lower': 0.62; 'skip:m 20': 0.63; 'pass': 0.64; 'subject:through':
0.69; 'you.': 0.71; '"when': 0.84; 'subject: \n ': 0.84; 'you:':
0.84
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048;
t=1716957206; bh=ri7rXS4XoLez8KCvRgoAQhb+qAcMft8GfpgMZiWcXhc=;
h=Date:From:To:Subject:References:From:Subject:Reply-To;
b=i8nCTVhrv+m2QPqYvA8ORVC24oP42pRtO/SrF1VVyolFDTPKSz/GliozKrCU/unx9HkDx5VEerFPxegzQUJuoY0tSvEKH3Gxex30qwe0DYVzlDfXDTj1Vz5SlkQ+uB6NHWWhlE+5CvlR2iV4kyE/PBG/+ZAX8PMYcTg0P7t7GPpB2k587ic5noao5J4F4DLyvZ23ic/quJ2jgUAZzklON+PAMgProLrgkeLBKAkYKW/FO+0qfi7GxqGT9icwzzzDX7Xgx0CRTg936JxywqZNB3ryGCce+PRDrxCoeHEId1+B/5W9BySj0yL5fc2gjTb44SIEfYWbMjufWSxP/EO3Lg==
X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048;
t=1716957206; bh=mlsif7o/71XLui0avxf3K1h5VqwjZSKGNuIoSX/CWSd=;
h=X-Sonic-MF:Date:From:To:Subject:From:Subject;
b=dBvRxqo2YOXvBFXkG5VnZTJeejdJwU+gQNmgEQxa9mjpdiV9ZWJkmkWzPhZBrbg2WE+fnM3qWOMkzsXnZ4RsJQiSAD19TABczvUXj6O+PObpDDstrzs5DaLofiq+v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.vJMVCFp2J3ZSEL5k5FDwYOONzWHeoG
tCkT7Pketf2B99qoCuV7lixus1nvY20V8i0EDiijduOIfrmazLjRd8eL9GxYp924i.z_PafRq8mX
U5q4HbyQ5CnG2SsQwmotkB1Mbnd4yyOJAGhHp3eaOMAcJqHZLquZzNN8gZt745pBPiy7g9ZryBPi
zxALJ4T3FcwiTxpvxe5odqeDlwLDUV1SS2FfHpytG3xeSZPqKASOJVPSQBQ_5dt_8Go_c4g7son1
SFxIx6oNcLeF3jvISnzaXBfuDNaJa.0ktY6z_tsODj7mSkANS8kdFJWyEPmrc9tHiiQaSWZ6PFsH
EBEeuw5Erg4isOx0Xdz1B4tMtmywMjZIA33.sa_JUpsA-
X-Sonic-MF: <kevinmwilson1956@yahoo.com>
X-Sonic-ID: d4eb862a-2b39-4133-8ad0-88a50f84ea01
X-Mailer: WebService/1.1.22356 YMailNorrin
X-Content-Filtered-By: Mailman/MimeDel 2.1.39
X-BeenThere: python-list@python.org
X-Mailman-Version: 2.1.39
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: <https://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>
X-Mailman-Original-Message-ID: <1901134155.5453771.1716957203090@mail.yahoo.com>
X-Mailman-Original-References: <1901134155.5453771.1716957203090.ref@mail.yahoo.com>
View all headers

The following is my effort to understand how to process a string, letter, by letter:
def myfunc(name):        index = 0    howmax = len(name)    # while (index <= howmax):    while (index < howmax):        if (index % 2 == 0):            print('letter to upper = {}, index {}!'.format(name[index], index))            name = name[index].upper()            print('if block {} and index {}'.format(name[index], index))        elif (index % 2 > 0):            print(index)            print('Start: elseif block, index is {}, letter is {}'.format(index, name))            # print('letter to lower = {}'.format(name[index]))            # print('Already lowercase do noting: name = {}'.format(name[index]))        index += 1        # index = name.upper()        
    return name        
myfunc('capitalism')
Error message:                        Not making sense, index is 1, letter s/b 'a'letter to upper = c, index 0!
if block C and index 0
1 Start: elseif block, index is 1, letter is C
---------------------------------------------------------------------------
IndexError Traceback (most recent call last)
Cell In[27], line 21
17 # index = name.upper()
19 return name
---> 21 myfunc('capitalism')

Cell In[27], line 8, in myfunc(name)
6 while (index < howmax):
7 if (index % 2 == 0):
----> 8 print('letter to upper = {}, index {}!'.format(name[index], index))
9 name = name[index].upper()
10 print('if block {} and index {}'.format(name[index], index))

IndexError: string index out of range***************************************************
So, I'm doing something... Stupid!!
***************************************************
"When you pass through the waters, I will be with you: and when you pass through the rivers, they will not sweep over you. When you walk through the fire, you will not be burned: the flames will not set you ablaze."     
Isaiah 43:2

Subject: Re: Flubbed it in the second interation through the string: range error... HOW?
From: Stefan Ram
Newsgroups: comp.lang.python
Organization: Stefan Ram
Date: Wed, 29 May 2024 11:59 UTC
References: 1 2 3
Path: eternal-september.org!news.eternal-september.org!feeder3.eternal-september.org!fu-berlin.de!uni-berlin.de!not-for-mail
From: ram@zedat.fu-berlin.de (Stefan Ram)
Newsgroups: comp.lang.python
Subject: Re: Flubbed it in the second interation through the string: range error... HOW?
Date: 29 May 2024 11:59:20 GMT
Organization: Stefan Ram
Lines: 17
Expires: 1 Feb 2025 11:59:58 GMT
Message-ID: <process-20240529125819@ram.dialup.fu-berlin.de>
References: <1901134155.5453771.1716957203090.ref@mail.yahoo.com> <1901134155.5453771.1716957203090@mail.yahoo.com> <mailman.52.1716957209.2909.python-list@python.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-Trace: news.uni-berlin.de SOMB4dExmG8tLdzwFvoLrwwT7gq5acG9tfP6WAiYGYshxL
Cancel-Lock: sha1:i4OV0pcBEJlE/Ol2V0dAwCL0IHw= sha256:MoN5xbAaYJvNPp7+Jy47YdCM+TFT+vtuWPUum2M746Y=
X-Copyright: (C) Copyright 2024 Stefan Ram. All rights reserved.
Distribution through any means other than regular usenet
channels is forbidden. It is forbidden to publish this
article in the Web, to change URIs of this article into links,
and to transfer the body without this notice, but quotations
of parts in other Usenet posts are allowed.
X-No-Archive: Yes
Archive: no
X-No-Archive-Readme: "X-No-Archive" is set, because this prevents some
services to mirror the article in the web. But the article may
be kept on a Usenet archive server with only NNTP access.
X-No-Html: yes
Content-Language: en
View all headers

"Kevin M. Wilson" <kevinmwilson1956@yahoo.com> wrote or quoted:
>The following is my effort to understand how to process a
>string, letter, by letter:

The term "process" is a description of the utmost vagueness,
failing to elucidate your intended actions. Thus, I would
counsel you to first articulate in the English vernacular the
objectives you wish to attain, such that any individual could
compose the code in accordance with said English text.

The notion of desiring to manipulate a sequence of characters
in a "character by character" fashion could potentially
be a vestigial remnant of prior knowledge acquired from other
programming languages. Perchance, one might adopt an entirely
disparate approach in Python to accomplish what you truly aspire
to achieve. Ergo, it is imperative that we comprehend your genuine
objectives, so as to proffer you the most optimal assistance.

1

rocksolid light 0.9.8
clearnet tor