简体   繁体   中英

Can I get Last Digit of an Integer in Python

I am Trying to Find the Last Digit of my Integer. but unable to find it.

Note - I am Using.split() in my Working Dish.

# 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)

I want to Wrap up all the things with this Error.

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
>>> 

I need serious help. You can Also Share Your code below if you want me to Understand Greatly. Till then zeez!

word(0)

TypeError: 'str' object is not callable

word[0]

Should work.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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