私はD & Dスタイルのキャラクタージェネレーターを作っています。私はそれらのための統計をロールして、彼らが望む能力スコアにそれらを割り当てることを許可します。私は彼らが同じセクションで再び同じセクションで戦っていたからスタートする能力を持っていたいと思っています。ここでリストと複数の入力を試してみよう
は私が
from random import randint
def char_stats():
# roll 4 D6s drop the lowest number and add the highest 3
s1,s2,s3,s4,s5,s6 = ([],[],[],[],[],[])
for x in range(4):
s1.append(randint(1,6))
s2.append(randint(1,6))
s3.append(randint(1,6))
s4.append(randint(1,6))
s5.append(randint(1,6))
s6.append(randint(1,6))
stat1 = sorted(s1)
stat2 = sorted(s2)
stat3 = sorted(s3)
stat4 = sorted(s4)
stat5 = sorted(s5)
stat6 = sorted(s6)
return sum(stat1[1:]),sum(stat2[1:]),sum(stat3[1:]),sum(stat4[1:]),sum(stat5[1:]),sum(stat6[1:])
a = list(char_stats())
print "Please choose one of the following for your stat: {}".format(a)
while len(a) > 0:
try:
Strength = int(raw_input('Please input one of these stats for your Strength:\n'))
if Strength in a:
a.remove(Strength)
print a
Wisdom = int(raw_input('Please input one of these stats for your Wisdom:\n'))
if Wisdom in a:
a.remove(Wisdom)
print a
Intelligence = int(raw_input('Please input one of these stats for your Intelligence:\n'))
if Intelligence in a:
a.remove(Intelligence)
print a
Constitution = int(raw_input('Please input one of these stats for your Constitution:\n'))
if Strength in a:
a.remove(Constitution)
print a
Dexterity = int(raw_input('Please input one of these stats for your Dexterity:\n'))
if Dexterity in a:
a.remove(Dexterity)
print a
Charisma = int(raw_input('Please input one of these stats for your Charisma:\n'))
if Charisma in a:
a.remove(Charisma)
except ValueError:
print "Incorrect Input"
continue
持っているものである私は(私は非常に悪い形であると考えている)if文のそれぞれをネストしようとしたと同様の結果を持っています。私はまた、すべての入力をtryではなく、計算にグループ化してみて、同じ結果を得ました。何かアドバイス?
私は少し動いてしまいます。私はあなたが行っている論理を見ています。私はもう少し詳しく説明します。 –
素晴らしい!楽しむ! – Prune