+ 1
How can i make a function that takes two inputs lets say a certain number and an array of numbers and i want the function to return the remainders of dividing the number by the numbers in the array?
4 Respostas
+ 5
No problem, don't forget to like the code if it helped you :D
+ 4
It's a one-liner, see for yourself ;)
https://code.sololearn.com/cSBRlV1pDLo4/?ref=app
+ 2
An alternative would be to use the built-in map function.
map(lambda x: number % x, array)
I do not know which solution is better. Kuba's looks more Pythonic - I personally find mine more intuitive. Anyway, in most cases I'd let the rem function return the generator or map object and make the conversion to list only when necessary (does not matter in this case though).
+ 1
Thank you