简体   繁体   English

为什么我不能将两个变量附加为一个元组

[英]Why can I not append two variables as a tuple

list = []
tuples = ((0,1),(1,1),(2,2),)
x = 0
y = 2
list.append([[], tuples + (x,y)])
print(list)

Im using This code as part of a tic tac toe AI to construct a tree however when appending this new list to the main list the tuples value reads as ((0,1),(1,1),(2,2),0,2).我使用此代码作为井字游戏 AI 的一部分来构建一棵树,但是当将此新列表附加到主列表时,元组值读取为 ((0,1),(1,1),(2,2), 0,2)。 I intend for the x and y variables to be as part of a single tuple like so:((0,1),(1,1),(2,2),(0,2)) What am I doing wrong here?我打算将 x 和 y 变量作为单个元组的一部分,如下所示:((0,1),(1,1),(2,2),(0,2)) 我在这里做错了什么? thank you in advance先感谢您

list = []
tuples = ((0,1),(1,1),(2,2),)
x = 0
y = 2
list.append([[], tuples + ((x,y),)])
print(list)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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