Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
@irene think of it as "breaking open" collections into individual elements. For example, if I have this function:
def foo(a,b,c):print(a,b,c)
I can provide all the arguments via an array and *:
foo(*[1,2,3])
Personally, I find it useful for printing an array by separating elements by a space:
print(*array)
https://codeyarns.com/2012/04/... -
Related Rants
// Task: add one to the input number
// Sane people:
// print(int(input())+1)
// Me:
n = [*(reversed(bin(int(input()))[2:]))]
tmp = ""
for i in range(len(n)):
tmp = n[i]
tmp = "1" if tmp == "0" else "0"
n[i] = tmp
if tmp == "1":break
if tmp == "0":n+=["1"]
n = "".join(reversed(n))
n = int(n,2)
print(n)
random
over engineering
why
python
send help