Question: I do not know how to define the two inputs (martian and plutonian)

Question

I do not know how to define the two inputs (martian and plutonian)

Answers 0
Added at 2016-12-03 11:12
Tags
Question

My code is simple yet the error has me baffled.

The following is my code:

from random import randint #I import the required modules for this program to work

character = input("What character would you like to play martian or plutonian? \n>>") #I define the character variable and ask the player which character they would like to play

if character:  "martian"     #I make an if statement that works only if the player chooses the Marian character
  strength = (randint(3, 20))     #I set the range for the strength variable and allow the computer to randomly generate a value within this range
  speed = (randint(5, 15))        #I set the range for the speed variable and allow the computer to randomly generate a value within this range
  height = (randint(1.2, 1.83))   #I set the range for the height variable and allow the computer to randomly generate a value within this range
  heart_rate = (randint(60, 110)) #I set the range for the heart rater variable and allow the computer to randomly generate a value within this range

  print("The strength of your martian is" ,strength)    #This prints the value of the strength variable
  print ("The speed of your martian is",speed)      #This prints the value of the speed variable
  print("The height of your martian is",height)      #This prints the value for the height variable
  print ("The heart rate of your martian is",heart_rate) #This prints the value of the height rate variable

if character:  "plutonian"     #I make an if statement that works only if the player chooses the Marian character
  strength = (randint(3, 20))     #I set the range for the strength variable and allow the computer to randomly generate a value within this range
  speed = (randint(5, 15))        #I set the range for the speed variable and allow the computer to randomly generate a value within this range
  height = (randint(1.2, 1.83))   #I set the range for the height variable and allow the computer to randomly generate a value within this range
  heart_rate = (randint(60, 110)) #I set the range for the heart rater variable and allow the computer to randomly generate a value within this range
  print("The strength of your character is" ,strength)    #This prints the value of the strength variable
  print ("The speed of your character is",speed)      #This prints the value of the speed variable
  print("The height of your character is",height)      #This prints the value for the height variable
  print ("The heart rate of your character is",heart_rate) #This prints the value of the height rate variable

The following is my error:

File "C:/Users/megam/PycharmProjects/Year 10/Martians & Plutonians.py", line 2, in <module>
    character = input("What character would you like to play martian or plutonian? \n>>") #I define the character variable and ask the player which character they would like to play
  File "<string>", line 1, in <module>
NameError: name 'martian' is not defined
Answers
Source Show
◀ Wstecz