Pull it together


#1

I keep getting this error message on pulling it together. any idea why?


#2

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?)


#3


#4

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.


#5

i did it and that fixed it thank you. would that matter in coding or just here cause thats what it expects to get?


#6

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


#7

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.


#8

okay so now that that is fixed. whats the reason this wouldn't print to the console?


#9

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'

#10

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?


#11

thank you so much you point out just enough to help me see the problem without saying it directly


#13


#14

Where are the function parameters (input variables) when you called the function in the print statement?
The function won't do anything if there isn't any input.


#15

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 :stuck_out_tongue:


#16

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.