为啥我的二次命名不管用呢?
想让用pop 删除的表示出来这个three 跟four 怎么有毛病啊
names=['zhanglinxia','chenmeiqi','wuyan']
one_names=names.pop(1)
two_names=names.insert(2,'yuyang')
print(names.title()+",nice to meet you!")
print(names.title()+",nice to meet you!")
print(names.title()+",nice to meet you!")
print("sorry,I can only visit one guests!")
three_names=names.pop(2)
four_names=names.pop(1)
print('sorry,I can't visit '+three_names.title())
print('sorry,I can't visit '+four_names.tilte())
print(names.title()+',nice to meet you!')
File "<ipython-input-15-d579e0eea14a>", line 13
print('sorry,I can't visit '+three_names.title())
^
SyntaxError: invalid syntax
显示结果有问题,哪里错了呢?
本帖最后由 LuLD 于 2020-9-16 15:45 编辑
print('sorry,I can't visit '+three_names.title()) 因为 这个单引号,导致后面成了非法字符
can ' t,中间的那个单引号 与 sorry前的单引号 成了一对儿
一定要用的话换成双引号或者 加上转义符 \
print(”sorry,I can't visit“+three_names.title())
还有 print('sorry,I can't visit '+four_names.tiltle())four 少了 一个L 果然是这个原因,感谢! 怎么看不到最佳答案了?我想给你的答案设置一下来着,找不到哪里可以选择最佳答案了
页:
[1]