Re: some problems for an introductory python test

2021-08-11 Thread Wolfram Hinderer via Python-list
Am 11.08.2021 um 05:22 schrieb Terry Reedy: Python is a little looser about whitespace than one might expect from reading 'normal' code when the result is unambiguous in that it cannot really mean anything other than what it does.  Two other examples: >>> if3: print('yes!') yes! >>> [0]  [0]

Re: count consecutive elements

2021-01-14 Thread Wolfram Hinderer via Python-list
Am 13.01.2021 um 22:20 schrieb Bischoop: I want to to display a number or an alphabet which appears mostly consecutive in a given string or numbers or both Examples s= ' aabskaaabad' output: c # c appears 4 consecutive times 8bbakebaoa output: b #b appears 2 consecutive times You can

Re: best way to remove leading zeros from a tuple like string

2018-05-21 Thread Wolfram Hinderer via Python-list
Am 21.05.2018 um 01:16 schrieb bruceg113...@gmail.com: If I decide I need the parentheses, this works. "(" + ",".join([str(int(i)) for i in s[1:-1].split(",")]) + ")" '(128,20,8,255,-1203,1,0,-123)' Thanks, Bruce Creating the tuple seems to be even simpler. >>> str(tuple(map(int, s[1:-1].s