Ich versuche, eine Liste zu nehmen, share_list
, und dann nacheinander durch die Liste und produzieren eine Ausgabe, die auf das Ergebnis zugeschnitten ist. Ich habe zwei Probleme: Ich weiß nicht, wie man durch die Liste eine for
-Schleife, und ich erhalte diese Störung:TypeError: unorderable Typen: str() <= int()
Traceback (most recent call last):
File "C:\Users\Andrew\Documents\Python Projects\DataAnalytics\algorithm.py", line 9, in <module>
if check_pb_ratio.get_price_book() <= 1:
TypeError: unorderable types: str() <= int()
from yahoo_finance import Share
share_list = ['AAPL', 'GEVO', 'PTX']
for ticker in share_list:
check_pb_ratio = Share(share_list[0])
if check_pb_ratio.get_price_book() <= 1:
print(str(check_pb_ratio.get_price_book()))
else:
print("P/B Ratio is too high.")
Es scheint, dass 'check_pb_ratio.get_price_book()' eine Zeichenfolge ist. versuche es vor dem 'if' zu drucken. – xmcp
'share_list [0]' -> 'ticker',' check_pb_ratio.get_price_book() '->' float (check_pb_ratio.get_price_book()) '. Erwägen Sie, Google und/oder ein Python-Tutorial zu verwenden. –