#๐Ÿ”’ I Screwed Up

14 messages ยท Page 1 of 1 (latest)

runic gorge
#

So essentially I want it to greet the player and say "ohh this and that" according to what I coded, and then created a character. Though when it asked "do you wanna play again?" and said yes then these showed up: (see image above)

My code worked perfectly fine but I wanted to change it so they can fight, I also wanna store their characters ina dictionary and they can choose whoever they wanna fight and it'll roll a dice to see who won>

here's the code I used.

neat hullBOT
#

@runic gorge

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

runic gorge
#

import random, os, time


def diceRollSix(number):
  dice = random.randint(1, number)
  return dice
diceRollSix(6)

def diceRollTwelve(number):
  dice = random.randint(1, number)
  return dice 
diceRollTwelve(12)

def Character():
  print("""Choose Your Character!
  Put the name of your character and choose from the following for the classes: 
    1. Wizard
    2. Warrior
    3. Normal
    4. Imp
    5. Elf""")
  print()
  classForCharacters = ["Wizard", "wizard", "Warrior" "warrior", "normal", "Normal", "Imp" "imp", "Elf", "elf"]

  nameChara = input("Name of your character: ")
  classChara = input("Class of your character: ")

  while True: 
    if classChara not in classForCharacters:
      print("Please choose from the classes stated above.")
      classChara = input("Class of your character: ")

    elif classChara in classForCharacters:
      health = (diceRollSix(6) * diceRollTwelve(12))/2 + 10
      print(f"Your character's health is {health}.")
      print()
      strength = (diceRollSix(6) * diceRollTwelve(12))/2 + 12
      print(f"Your character's strength is {strength}.")
      
      characterStatsDict = {}
      characterStatsDict["name"] = nameChara
      characterStatsDict["class"] = classChara
      characterStatsDict["strength"] = strength
      characterStatsDict["health"] = health
      
      break 

def playAgain():
    playBuilderAgain = input("Would you like to play again? > ")
    if playBuilderAgain == "yes" or playBuilderAgain == "Yes":
      Character()
      return True
    else:
      exit() 
  
while True: 
  intro = input("Welcome to the character builder! Would you like to play? > ")
  print()
  if intro == "yes" or intro == "Yes":
    print("Great! Let's get started! Please waita second for this the menu to load!")
    time.sleep(1)
    os.system("clear")
  else: 
   break 

  Character()
  playAgain()

if playAgain() == "yes" or playAgain() == "Yes":
  pass
else:
  exit() 


    ```
uneven radish
#

Looking at your code, it seems your functions are either returning or they're not

#

hmm

#

Like for instance, the Character() function needs to return characterStatsDict

#

instead of break

runic gorge
#

ah I see

#

ty

neat hullBOT
#
Python help channel closed

This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.

#

๐Ÿ”’ I Screwed Up