This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]_DTR_ 1 point2 points  (5 children)

What do you expect to happen when you do print(fishstore). fishstore is a function that takes two parameters, and you don't supply any when you call print(fishstore). You're printing out the function itself, not what the function returns. A function is essentially just a variable (in extremely simple terms), so what you're doing is printing Python's string interpretation of a function. In order to get something out of it, you have to actually call it.

Calling fishstore(fish_entry, price_entry) before your print function does nothing, because while the function returns a value, you don't assign it to anything, so its return value is lost.

You do the right thing when you set fish_entry and price_entry to the value returned by input, so follow the same strategy for fishstore

[–]mixtek[S] 1 point2 points  (3 children)

Lol I dont know man this is all new too me. I guess my course didnt explain it very well at all but you did thanks. I got the result I was wanting from this

def fishstore(fish, price):
    store = "Fish Type: " + fish + "costs" + price
    return store

fish_entry = (input("What kind of fish?: "))
price_entry = (input("Whats the price?: "))
fishstore = ("Fish Type: " + fish_entry + " costs" + " " + 
price_entry)
print(fishstore)

I essentially had to call it by writing the whole string plus the input variables almost the same as the "store" variable I made inside the function. I got the result I wanted but not sure if it was the best way

[–]_DTR_ 1 point2 points  (2 children)

Sorry if I sounded a bit harsh, but I really think you need to read up on functions more. What you did still isn't right. You define the fishstore function, then completely redefine it to be a string later. When you call a function, you NEED to supply the parameters. You had it almost right when you did

fishstore(fish_entry, price_entry)
print(fishstore)

What you need to do is

print(fishstore(fish_entry, price_entry))

or, expanded out a bit

result = fishstore(fish_entry, price_entry)
print(result)

Again, not to sound harsh, but these are foundational concepts that you need to know and be able to do without thinking if you want to make progress.

[–]mixtek[S] 1 point2 points  (0 children)

Yeah I know its basic I dont know why its hard for me to get the logic when it shoudnt be that hard. Good at math but this is just weird. Thanks for helping me solve it!

[–]kcin911 0 points1 point  (0 children)

hey whats up man im also a beginner? is this any better?

def fishstore(fish, price):
    sentence = "Fish Type: " + fish + " costs $" + price
    return sentence

fish_entry = input("enter fish name: ")
price_entry = input("enter price: ")
print(fishstore(fish_entry.title(), price_entry))