+ 3

I want add 3 to start and end of 253 number in Python. How i can do it.

question

24th Dec 2017, 8:17 AM
Yunis Hüseynzadə
Yunis Hüseynzadə - avatar
9 Respuestas
24th Dec 2017, 9:15 AM
Sebastian Keßler
Sebastian Keßler - avatar
24th Dec 2017, 10:50 AM
Oma Falk
Oma Falk - avatar
+ 6
print(3,253,3,sep='') it is a bit more pythonic perhaps
24th Dec 2017, 8:37 AM
Oma Falk
Oma Falk - avatar
+ 5
list = [3,253,3] print(''.join(list))
24th Dec 2017, 10:20 AM
Oma Falk
Oma Falk - avatar
24th Dec 2017, 12:03 PM
Sebastian Keßler
Sebastian Keßler - avatar
+ 3
You may transform the number into a string and then add the characters: number = 253 print (int('3'+str(number)+'3'))
24th Dec 2017, 8:26 AM
Sebastian Keßler
Sebastian Keßler - avatar
+ 2
thanks
24th Dec 2017, 8:34 AM
Yunis Hüseynzadə
Yunis Hüseynzadə - avatar
+ 2
thanks
24th Dec 2017, 9:23 AM
Yunis Hüseynzadə
Yunis Hüseynzadə - avatar
+ 2
Using the last char index: num = '253' print(int(num[-1] + num + num[-1]))
4th Feb 2018, 10:52 PM
FarinHeiT
FarinHeiT - avatar