【发布时间】:2020-07-23 01:30:36
【问题描述】:
我正在尝试查找整数的最后一位。但无法找到它。
Note -我正在工作盘中使用 .split()。
# cooking my dish here
x = str(input())
letters = ""
words = x.split()
for word in words:
letters += word[0]
a = int(word(0) + word[-1])
print(a)
我想用这个错误来结束所有的事情。
21
Traceback (most recent call last):
File "E:\testererterset.py", line 9, in <module>
a = int(word(0) + word[-1])
TypeError: 'str' object is not callable
>>>
我需要认真的帮助。如果您希望我非常了解,您也可以在下面分享您的代码。 到那时为止!
【问题讨论】:
-
word(0)->word[0] -
您使用圆括号来获取第一个字符:a = int(word(0) + word[-1]) 这是错误的,您需要将其写为:a = int(word [0] + 单词[-1])
标签: python function split integer typeerror