簡體   English   中英

我可以在 Python 中獲得 Integer 的最后一位嗎

[英]Can I get Last Digit of an Integer in Python

我正在嘗試查找我的 Integer 的最后一位數字。 但無法找到它。

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)

類型錯誤:'str' object 不可調用

word[0]

應該管用。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM