0
I really can't justify use of an Empty tuple... a tuple is immutable.. so it should remain empty everytime what can be it's use?
Google it.... & find a Sololearn link.. but I can't understand that https://www.sololearn.com/discuss/536893/?ref=app
3 Respostas
+ 5
The only use I can think of right now is to pass an empty tuple to a method which requires tuples as arguments, to later use it within that function.
You're right, though - it can't be changed/modified so it will just stay like this - ()
+ 4
Well, if you have in your code flow a method which outputs a tuple based on some condition and another method, which takes it as an argument and outputs a result as a list, based on the tuple - this second method will take an empty tuple as argument.
def tup(a):
....
return tuple(a)
def lis(b): # where b is tuple
....
return list(b[::]).append("OK")
Now if b is empty, the code will still work and only output "OK".
0
tuple as argument...& what it does sir?