I receive
TypeError: Can't convert 'float' object to str implicitly
while using
Gambler.pot += round(self.bet + self.money * 0.1)
where pot, bet, and money are all doubles (or at least are supposed to be). I'm not sure if this is yet another Eclipse thing, but how do I get the line to compile?
Code where bet
and money
are initialized:
class Gambler:
money = 0
bet = 0
Test case:
number = 0
print("Here, the number is a {0}".format(type(number)))
number = input("Enter in something: ")
print("But now, it has turned into a {0}".format(type(number)))
Output from test case:
Here, the number is a <class 'int'>
Enter in something: 1
But now, it has turned into a <class 'str'>
Apparently, input() is changing it to a string.
EDIT: Finally fixed the problem (I think) with
self.bet = int(self.bet.strip())
after the user inputs the value. Though I dunno if that's the best way to fix the problem :)
A better solution by Daniel G.:
self.bet = float(input("How much would you like to bet? $"))