List_of_numbers1to19 = ['one', 'two', 'three', 'four', 'five', 'six', 'seven',
'eight', 'nine', 'ten', 'eleven', 'twelve', 'thirteen',
'fourteen', 'fifteen', 'sixteen', 'seventeen', 'eighteen',
'nineteen']
List_of_numbers1to9 = List_of_numbers1to19[0:9]
List_of_numberstens = ['twenty', 'thirty', 'fourty', 'fifty', 'sixty', 'seventy',
'eighty', 'ninety']
for i in List_of_numbers1to19:
print(i)
list_of_numbers21to99 = []
count = 19
tens_count = 0
for j in List_of_numberstens:
for k in List_of_numbers1to9:
if tens_count%10 == 0:
#should print an iteration of List_of_numberstens
tens_count +=1
tens_count +=1
print(j, k)
ご覧のとおり、これは面倒です。Pありがとうございました。 基本的には、異なるインデックスを持つ3つの異なるfor-loopsを使用してそれらを印刷しようとしています。私はリストのスライスとリストのインデックス作成を試みましたが、List_of_numberstens
の完全なリストとして10を掛け合わせることができます。Python 3の単語として1〜100の数字を印刷します
私がここでやろうとしていることは明らかです。
ご協力いただきありがとうございます。
読む[num2words]で 'dict's – dawg
ルックについて(https://pypi.python.org/pypi/num2words) – dawg
:私はちょうど、より多くのループのための埋め込みループの仕組みを理解したいと思います。 – snuffles101