You’ve used the type() function before, earlier in your code. This should be similar to the previous times you’ve used type. Can you see any differences in the way you’ve used it here?
Sorry but your last post was over my head. I don’t know what you’re talking about and have never used google collab. Could you break down what your were trying to say here?
Google collab is a website/coding platform and it’s easy to open a window and test out some Python code. I use it a lot if I want to test something quickly and not mess up something I’m working on in fCC.
You need to test your ideas out to see if they work and play around with it and print results to understand what you’re doing. Google Colab is a good platform for that.
if type(5) == (int, float):
This is never going to work because type(5) is not equal to (int, float)
Thanks I did try to put that after my code, but the first time I didn’t realize that copy / pasting messed with the indentation. The way it was it didn’t print anything or throw any errors.
I see what it printed, but I don’t know how to handle that. Do I need two separate statements, one for each option?
Like I said I’m completely lost on this step. Here’s what I’ve got so far:
def __mul__(self, other):
if type(other) == (int):
kwargs = {i: getattr(self, i) * other for i in vars(self)}
if type(other) == (float):
kwargs = {i: getattr(self, i) * other for i in vars(self)}
return self.__class__(**kwargs)
def __mul__(self, other):
if type(other) == (int):
kwargs = {i: getattr(self, i) * other for i in vars(self)}
return self.__class__(**kwargs)
if type(other) == (float):
kwargs = {i: getattr(self, i) * other for i in vars(self)}
return self.__class__(**kwargs)