I keep getting this error message on pulling it together. any idea why?
Seems like a straight-forward thing to fix, define the name it says isn't defined. Is there some problem in doing that? (If so, what?)
It would seem that your parameters in your trip cost def are backwards. I believe it should be (city, days) instead of (days, city) because of how the lesson wants you to in returning have the city first then the day. Please notice what order the instructions give you them in: "
Below your existing code, define a function called trip_cost that takes two arguments, city and days." @ionatan seemingly it is but I could see how you wouldn't expect the error to be where it is based on the error that is gives back. At least I would be confused.
i did it and that fixed it thank you. would that matter in coding or just here cause thats what it expects to get?
Yeah just trying to get everyone to identify/pin down the problem so that there's something they can reason about. And if I know why they can't continue then I can pick at only the thing that went wrong or point at the next thing to look at
Ok here is what I have gathered from my research and @ionatan can correct me if I am wrong: well the error unsupported operand type(s) for -: 'int' and 'str' is referring to the fact that you have both a string and an integer in that same line of python code. Python cannot add these two different types together. Usually, python wants either both strings or both integers but not one of each. Now, why to the fact that changing city first and days second allows this to happen even though you still get a string and an integer... it would seem that some form of concatenation or behind the scenes magic would need to take place. "Concatenation (from Latin concatenare, to link together) is taking two or more separately located things and placing them side-by-side next to each other so that they can now be treated as one thing" Quotation Source: http://whatis.techtarget.com/definition/concatenation-concatenate-concatenating Seemingly, either the string and integer is turned behind the scenes into matching types or some form of concentration is happening to where they are being combined into one type to avoid error. Once again, take this with a grain of salt, but that would be my best guess just on doing a quick research on the error and Python dealing with that error.
The operator is
>>> 5 - 'hello' Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: unsupported operand type(s) for -: 'int' and 'str'
Why would it print anything? Your code creates 4 functions and then it reaches the end of file. It does nothing else.
Perhaps some other code should come before the end of the file?
thank you so much you point out just enough to help me see the problem without saying it directly
Where are the function parameters (input variables) when you called the function in the
The function won't do anything if there isn't any input.
rental_cast_costs ("s" delete in final of the line)
is a error of variable global not defined in code
change rental_cast_costs ------->> rental_cast_cost ( is the name of second function defined)
my english is terrible
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.