TypeError: unsupported operand type(s) for -: ‘str’ and ‘str’

value=(yahoostock.get_price('RIL.BO'));

Apparently returns a string not a number. Convert it to a number:

value=int(yahoostock.get_price('RIL.BO'));

Also the signal-to-noise ratio isn’t very high. You’ve lots of (,), and ; you don’t need. You assign variable only to replace them on the next line. You can make your code nicer like so:

money = 1000000
value = int(yahoostock.get_price('RIL.BO'));
portfolio = 16 * value;
print id(portfolio);
print id(value);
money -= portfolio;

Leave a Comment