Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Python
  4. FLAMES game in python

FLAMES game in python

Scheduled Pinned Locked Moved Python
pythongame-devhelptutorialquestion
3 Posts 2 Posters 15 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Offline
    G Offline
    ganga devi 2023
    wrote on last edited by
    #1

    # 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 ?

    L 1 Reply Last reply
    0
    • G ganga devi 2023

      # 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 ?

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      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 the while statement above is correct. Try replacing it with if instead, thus:

      if number > 1:

      [/edit]

      G 1 Reply Last reply
      0
      • L Lost User

        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 the while statement above is correct. Try replacing it with if instead, thus:

        if number > 1:

        [/edit]

        G Offline
        G Offline
        ganga devi 2023
        wrote on last edited by
        #3

        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

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups