n=raw_input() if eval("+".join(n[:3])) == eval("+".join(n[3:])): print "Счастливый" else: print "Обычный"
n=raw_input() if eval("+".join(n[:3])) == eval("+".join(n[3:])): print "Счастливый" else: print "Обычный"
>>> a=2015
>>> b=a[:2]
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: 'int' object is not subscriptable
>>> a=2015 >>> b=int(str(a)[:2]) >>> print type(a), type(b), "a=%s, b=%s"%(a, b) <type 'int'> <type 'int'> a=2015, b=20
Originatorздесь все правильно. Операция среза не предусмотрена для стандартных типов данных int.
Если не прав, научите.
a = int(input()) s1 = (a // 100000) + (a // 10000 % 10) + (a // 1000 % 10) s2 = (a % 1000 // 100) + (a % 1000 // 10 % 10) + (a % 1000 % 10) if s1 == s2: print("Счастливый") else: print("Обычный")
number = list(map(int, input())) print('Lucky' if sum(number[:3]) == sum(number[3:]) else 'Normal')