Re: Is there a way to subtract 3 from every digit of a number?

2021-02-20 Thread 2QdxY4RzWzUUiLuE
On 2021-02-20 at 20:49:15 -0800, Dan Stromberg wrote: > On Sat, Feb 20, 2021 at 7:13 PM Ming wrote: > > > I just wrote a very short code can fulfill your needs: > > > > a = 2342 > > b = int("".join(map(lambda x: str((int(x)-3)%10) ,list(str(a) > > > I tend to favor plenty of temporary varia

Re: Is there a way to subtract 3 from every digit of a number?

2021-02-20 Thread Chris Angelico
On Sun, Feb 21, 2021 at 3:50 PM Dan Stromberg wrote: > > On Sat, Feb 20, 2021 at 7:13 PM Ming wrote: > > > I just wrote a very short code can fulfill your needs: > > > > a = 2342 > > b = int("".join(map(lambda x: str((int(x)-3)%10) ,list(str(a) > > > I tend to favor plenty of temporary variab

Re: Is there a way to subtract 3 from every digit of a number?

2021-02-20 Thread Dan Stromberg
On Sat, Feb 20, 2021 at 7:13 PM Ming wrote: > I just wrote a very short code can fulfill your needs: > > a = 2342 > b = int("".join(map(lambda x: str((int(x)-3)%10) ,list(str(a) > I tend to favor plenty of temporary variables with descriptive names, but this is indeed short. Apart from that,

Re: Is there a way to subtract 3 from every digit of a number?

2021-02-20 Thread Ming
On Sat, Feb 20, 2021 at 09:40:48AM -0500, C W wrote: > Hello everyone, > > I'm curious if there is a way take number and back each digit by 3 ? > > 2342 becomes 9019 > 8475 becomes 5142 > 5873 becomes 2540 > > The tricky part is that 2 becomes 9, not -1. > [...] I just wrote a very short code c

Re: Is there a way to subtract 3 from every digit of a number?

2021-02-20 Thread dn via Python-list
On 21/02/2021 06.02, jak wrote: > Il 20/02/2021 15:40, C W ha scritto: >> Hello everyone, >> >> I'm curious if there is a way take number and back each digit by 3 ? >> >> 2342 becomes 9019 >> 8475 becomes 5142 >> 5873 becomes 2540 >> >> The tricky part is that 2 becomes 9, not -1. >> >> Here's my t

RE: Is there a way to subtract 3 from every digit of a number?

2021-02-20 Thread Avi Gross via Python-list
Wouldn't it be nice, Grant, if Homework was assigned with statements like: "Using only the features of the language covered up to chapter 3, meaning individual variables and lists of them and simple loops and only using the arithmetic built-in variable of +, -, % ... Solve this problem " But

Re: use set notation for repr of dict_keys?

2021-02-20 Thread dn via Python-list
On 20/02/2021 20.25, Wolfgang Stöcher wrote: > Having a dict like >   d = {'one': 1, 'two': 2} > the representation of its keys >   repr(d.keys()) > gives >   "dict_keys(['one', 'two'])" > > But since the keys are unique, wouldn't a representation using the set > notation > be more intuitive, i.e.

Re: Is there a way to subtract 3 from every digit of a number?

2021-02-20 Thread Terry Reedy
On 2/20/2021 12:02 PM, jak wrote: Il 20/02/2021 15:40, C W ha scritto: Hello everyone, I'm curious if there is a way take number and back each digit by 3 ? 2342 becomes 9019 8475 becomes 5142 5873 becomes 2540 The tricky part is that 2 becomes 9, not -1. Here's my toy example and what I atte

Re: Is there a way to subtract 3 from every digit of a number?

2021-02-20 Thread Grant Edwards
On 2021-02-20, Dan Stromberg wrote: > Convert to a str. > Convert to a list of ints, one for each digit > Add 7 mod 10, for each digit in the list I'd probably subtract 3 (mod 10), so as to more obviously match the stated requirement. > Convert to a list of single-character str's > Catenate tho

Re: use set notation for repr of dict_keys?

2021-02-20 Thread Terry Reedy
On 2/20/2021 2:25 AM, Wolfgang Stöcher wrote: Having a dict like   d = {'one': 1, 'two': 2} the representation of its keys   repr(d.keys()) gives   "dict_keys(['one', 'two'])" But since the keys are unique, wouldn't a representation using the set notation be more intuitive, i.e. what about c

Re: Is there a way to subtract 3 from every digit of a number?

2021-02-20 Thread Grant Edwards
On 2021-02-20, MRAB wrote: > Have a look at the 'translate' method of the 'str' class. That's very clever, but being too clever on homework assignemnts doesn't always get a good grade. If they've just studied iteration, the modulus operator, and int/str conversions, then I'd avise using the "dum

Re: Is there a way to subtract 3 from every digit of a number?

2021-02-20 Thread Dan Stromberg
Convert to a str. Convert to a list of ints, one for each digit Add 7 mod 10, for each digit in the list Convert to a list of single-character str's Catenate those str's back together Convert to a single int On Sat, Feb 20, 2021 at 6:45 AM C W wrote: > Hello everyone, > > I'm curious if there

Re: Is there a way to subtract 3 from every digit of a number?

2021-02-20 Thread jak
Il 20/02/2021 15:40, C W ha scritto: Hello everyone, I'm curious if there is a way take number and back each digit by 3 ? 2342 becomes 9019 8475 becomes 5142 5873 becomes 2540 The tricky part is that 2 becomes 9, not -1. Here's my toy example and what I attempted, test_series = pd.Series(lis

Re: Is there a way to subtract 3 from every digit of a number?

2021-02-20 Thread MRAB
On 2021-02-20 14:40, C W wrote: Hello everyone, I'm curious if there is a way take number and back each digit by 3 ? 2342 becomes 9019 8475 becomes 5142 5873 becomes 2540 The tricky part is that 2 becomes 9, not -1. Here's my toy example and what I attempted, test_series = pd.Series(list(['2

use set notation for repr of dict_keys?

2021-02-20 Thread Wolfgang Stöcher
Having a dict like d = {'one': 1, 'two': 2} the representation of its keys repr(d.keys()) gives "dict_keys(['one', 'two'])" But since the keys are unique, wouldn't a representation using the set notation be more intuitive, i.e. what about changing the output of dict_keys.__repr__ to

Re: Is there a way to subtract 3 from every digit of a number?

2021-02-20 Thread 2QdxY4RzWzUUiLuE
On 2021-02-20 at 09:40:48 -0500, C W wrote: > Hello everyone, > > I'm curious if there is a way take number and back each digit by 3 ? > > 2342 becomes 9019 > 8475 becomes 5142 > 5873 becomes 2540 > > The tricky part is that 2 becomes 9, not -1. > > Here's my toy example and what I attempted,

Re: issue with seaborn

2021-02-20 Thread Cousin Stanley
Dino wrote: > trying to do some dayaviz with Italian Covid Open Data ( > https://github.com/italia/covid19-opendata-vaccini/ ) > > here's how I pull my data: > > import sys > import urllib.request > import pandas as pd > import ssl > ssl._create_default_https_context

Is there a way to subtract 3 from every digit of a number?

2021-02-20 Thread C W
Hello everyone, I'm curious if there is a way take number and back each digit by 3 ? 2342 becomes 9019 8475 becomes 5142 5873 becomes 2540 The tricky part is that 2 becomes 9, not -1. Here's my toy example and what I attempted, > test_series = pd.Series(list(['2342', '8475', '5873'])) > test_se

Overriding property types on instances from a library

2021-02-20 Thread Joseph L. Casale
I have some code that makes use of the typing module. This code creates several instances of objects it creates from a library that has some issues. For example, I have multiple list comps that iterate properties of those instance and the type checker fails with: Expected type 'collections.It

Re: issue with seaborn

2021-02-20 Thread Reto
Don't have the original email, hence replying this way. On Sat, Feb 20, 2021 at 12:13:30PM +0100, jak wrote: > Il 20/02/2021 01:56, Dino ha scritto: > > > > trying to do some dayaviz with Italian Covid Open Data ( > > https://github.com/italia/covid19-opendata-vaccini/ ) > > > > here's how I pull

Re: issue with seaborn

2021-02-20 Thread jak
Il 20/02/2021 01:56, Dino ha scritto: trying to do some dayaviz with Italian Covid Open Data ( https://github.com/italia/covid19-opendata-vaccini/ ) here's how I pull my data: import sys import urllib.request import pandas as pd import ssl ssl._create_default_http