Python OOPs


Python SQLite


Examples


Others


How to Create FLAMES Game Using Python


FLAMES game is know the relationship with their partner.This example shows how to create FLAMES game using JavaScript.

FLAMES stands for

  • F-Friend
  • L-Love
  • A-Affection
  • M-Marriage
  • E-Enemy
  • S-Sibling

Output

Enter First Name : Tom
Enter Second Name : Tiny Tom is Tiny's Friend
s1=input("Enter First Name : ")
s2=input("Enter Second Name : ")
name1=list(s1.lower())
name2=list(s2.lower())
for i,x in enumerate(name1):
    j="".join(name2).find(name1[i])
    if(j!=-1):
        name1[i]='*'
        name2[j]='*' 
        
x=lambda x: True if x!='*' else False 
a=[]
a.extend(list(filter(x,name1)))
a.extend(list(filter(x,name2)))
n=len(a)

flames=list("FLAMES")
i=0
c=0
while len(list(filter(x,flames)))!=1:
    if i==6:
        i=0      
    if flames[i]!='*':
        c+=1      
    if c==n:
        flames[i]='*'
        c=0       
    i+=1
result=''.join(list(filter(x,flames)))

flamesDict={
    'F':'Friend',
    'L':'Love',
    'A':'Affection',
    'M':'Marriage',
    'E':'Enemy',
    'S':'Sibling',
}
print("{} is {}'s {}".format(s1,s2,flamesDict[result]))