value_1 = float(input("your V1 is ")) value_2 = float(input("your V2 is ")) value_3 = float(input("your V3 is ")) value_4 = float(input("your V4 is ")) value_5 = float(input("your V5 is ")) print(value_1, value_2, value_3, value_4, value_5, sep=' and ') value_2 = 3 py_list = [value_1, value_2, value_3, value_4, value_5] var = py_list[0:4]+[3] print(var) py_tuple = (value_1, value_2, value_3, value_4, value_5) vay = tuple[0:4]+(value_1,) print(vay)哪里错了
时间: 2024-02-26 20:58:39 浏览: 94
pandas计数 value_counts()的使用
5星 · 资源好评率100%
在代码中,第15行 `vay = tuple[0:4]+(value_1,)` 是有问题的,应该使用 `py_tuple` 而不是 `tuple`。
正确的代码应该是:
```python
value_1 = float(input("your V1 is "))
value_2 = float(input("your V2 is "))
value_3 = float(input("your V3 is "))
value_4 = float(input("your V4 is "))
value_5 = float(input("your V5 is "))
print(value_1, value_2, value_3, value_4, value_5, sep=' and ')
value_2 = 3
py_list = [value_1, value_2, value_3, value_4, value_5]
var = py_list[0:4] + [3]
print(var)
py_tuple = (value_1, value_2, value_3, value_4, value_5)
vay = py_tuple[0:4] + (value_1,)
print(vay)
```
这样,代码就可以正确运行了。
阅读全文