Explore Courses Blog Tutorials Interview Questions
0 votes
1 view
in Data Science by (18.4k points)
edited by

I try to make the little text-based rpg with the python. First thing I want to make is my input to equip armor or weapons.

def find_armor(x):

    if x=="bad armor":


    if x=="good armor":




bad_armor=["bad armor",300]

good_armor=["good armor", 500]


option1,option2=input(">").split(" ",1)

if option1=="equip":





print("your armor:",armor_name,armor_point)

This is my problem:

The function find_armor is not calling whatever I try to enter.

If my first word is the "equip" then my output is always: your armor: 0 0

1 Answer

0 votes
by (36.8k points)

In the function, variables change with local scope. Then use the global armor before. And fixing your bad indentation:

def find_armor(x):

  global armor

  if x=="bad armor":

    global bad_armor


  elif x=="good armor":

    global good_armor


Improve your knowledge in data science from scratch using Data science online course 

Welcome to Intellipaat Community. Get your technical queries answered by top developers!

28.4k questions

29.7k answers


94k users

Browse Categories