python - NameError: name 'fish' is not defined -


i'm newbie in python , trying figure out problem i'm facing. i'm getting following error msg:

     16     return output      17  ---> 18 print(fishstore(fish, price))      19       20   nameerror: name 'fish' not defined 

script i'm working on:

def fishname():     user_input=input("enter name: ")     return (user_input.title())  def number():     number_input=input("enter price: ")     return number_input  def fishstore(fish, price):          fish_entry = fishname()          price_entry = number()         output = "fish type: " + fish_entry + ", costs $" + price_entry     return output  print(fishstore(fish, price)) 

could explain i'm missing?

thank in advance.

thank help. did work , made change...

def fishstore(fish, price):          output = "fish type: " + fish + ", costs $" + price     return output  fish_entry = input("enter name: ") fish = fish_entry price_entry = input("enter price: ") price = price_entry  print(fishstore(fish, price)) 

and worked. thank help!

when you're defining method you're naming arguments:

def fishstore(fish, price):  

when you're calling method you're referencing 2 variables don't exist:

fishstore(fish, price) 

you mean:

fishstore(fishname(), number()) 

the result of fishname() ends being fish within context of fishstore method, likewise number() becoming price. outside of specific context variables don't exist.


Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -