简体   繁体   中英

What does “numbers = (first, second) + rest” do?

What does numbers = (first, second) + rest do?

(first, second) is a tuple, so what does it mean to add something to a tuple?

Although just a guess, it safe to assume rest is also tuple and you add 2 tuples, eg something like this

first = 1
second = 2
rest = (3, 4, 5)
numbers = (first, second) + rest
print(numbers)

output:

(1, 2, 3, 4, 5)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM