FLAMES game in python
-
# Gives the name of the game print ("\t FLAMES") print ("\n") # Take input from user # And Saved them in lowercase name1 = input("Name of the first person : ").lower() name2 = input("Name of the second person : ").lower() print ("\n") # If there any space in between names # In this stage removing all the spaces rename1 = name1.replace(" ", "") rename2 = name2.replace(" ", "") # Added those name name = rename1 + rename2 # In here removing same characters for x in name: if name.count(x) != 1: name = name.replace(x,"") # Check total number of remaining characters number = len(name) # List of FLAMES acronym result = ["Friends","Love","Affection","Marriage","Enemy","Siblings"] while number > 1 : split_result = (number % len(result) -1) if split_result >= 0 : right = result[split_result + 1:] left = result[: split_result] result = right + left else: result = result[: len(result) - 1] print("Relationship status :", result[0]) #"split_result = (number % len(result) -1) " SHOWS THAT THERE IS ZERODIVITION ERROR HOW TO CORRECT THAT ?
-
# Gives the name of the game print ("\t FLAMES") print ("\n") # Take input from user # And Saved them in lowercase name1 = input("Name of the first person : ").lower() name2 = input("Name of the second person : ").lower() print ("\n") # If there any space in between names # In this stage removing all the spaces rename1 = name1.replace(" ", "") rename2 = name2.replace(" ", "") # Added those name name = rename1 + rename2 # In here removing same characters for x in name: if name.count(x) != 1: name = name.replace(x,"") # Check total number of remaining characters number = len(name) # List of FLAMES acronym result = ["Friends","Love","Affection","Marriage","Enemy","Siblings"] while number > 1 : split_result = (number % len(result) -1) if split_result >= 0 : right = result[split_result + 1:] left = result[: split_result] result = right + left else: result = result[: len(result) - 1] print("Relationship status :", result[0]) #"split_result = (number % len(result) -1) " SHOWS THAT THERE IS ZERODIVITION ERROR HOW TO CORRECT THAT ?
The issue is with the loop at:
while number > 1 :
split\_result = (number % len(result) -1) if split\_result >= 0 : right = result\[split\_result + 1:\] left = result\[: split\_result\] result = right + left else: result = result\[: len(result) - 1\]
You never decrement the value of
number
so the loop will continue forever, or until some exception occurs. But it is not clear what the code inside the loop is supposed to do, so that also may need some reworking. [edit] Having looked again at this code I am not sure that thewhile
statement above is correct. Try replacing it withif
instead, thus:if number > 1:
[/edit]
-
The issue is with the loop at:
while number > 1 :
split\_result = (number % len(result) -1) if split\_result >= 0 : right = result\[split\_result + 1:\] left = result\[: split\_result\] result = right + left else: result = result\[: len(result) - 1\]
You never decrement the value of
number
so the loop will continue forever, or until some exception occurs. But it is not clear what the code inside the loop is supposed to do, so that also may need some reworking. [edit] Having looked again at this code I am not sure that thewhile
statement above is correct. Try replacing it withif
instead, thus:if number > 1:
[/edit]
Thank you so much for your help sir .... I understand what mistake was i done. In while loop I typed " while number > 0: " that was the mistake i done. I changed that comment into " while len(reult) > 1:". Now its okey sir. Thank you sir ,Thank you so much for your valuble time