-
Notifications
You must be signed in to change notification settings - Fork 0
/
happy.py
36 lines (35 loc) · 848 Bytes
/
happy.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
a = raw_input("enter an input: ")
sum = 0
i = 0
while i < len(a):
b = a[i]
sum = 0
for k in a:
j = int(k)
sum = sum+(j**2)
if sum == 1:
print("happy")
break
else:
if sum == 4: #this is because, it will definitely loop through to come 42,0,16,20,4... if it is not a happy number, where it will break next
print "not happy"
break
else:
a = str(sum)
continue
i+=1
# user1 = input("enter a name: ")
# user2 = input("enter another name: ")
# if len(user1) == len(user2):
# a= list(user1)
# b= list(user2)
# a.sort()
# b.sort()
# for i in range(len(a)):
# if a[i] != b[i]:
# print ("not anagram")
# break
# else:
# print ("anagram")
# else:
# print ("not anagram")