0

ユーザーが選択した 5 つの異なるリストから 1 つの数字を印刷しようとしています。
これがコードです

import random

d = {'january':['1', '2', '3', '4', '5', '6', '7']
,'febuary':['1', '2', '3', '4', '5', '6', '7']
,'march':['1', '2', '3', '4', '5', '6', '7']
,'april':['1', '2', '3', '4', '5', '6', '7']
,'may':['1', '2', '3', '4', '5', '6', '7']
,'june':['1', '2', '3', '4', '5', '6', '7']
,'july':['1', '2', '3', '4', '5', '6', '7']
,'august':['1', '2', '3', '4', '5', '6', '7']}

items = raw_input("Pick 5 and separate them by a comma:" + ','.join(d)
item1, item2, item3, item4, item5 = items.split(',')

print 'picked:', random.choice(d[item1])

print 'picked:', random.choice(d[item2])

print 'picked:', random.choice(d[item3])

print 'picked:', random.choice(d[item4])

print 'picked:', random.choice(d[item5])

raw_input ()

私は取得し続けます

SyntaxError on line 13;
    item1, item2, item3, item4, item5 = items.split(',')

私も試してみました

items = raw_input("Pick 5 separated by comma:" + ','.join(d)
splitItems = items.split(',')

#print roles

print 'picked:', random.choice(d[splitItems[0]])
print 'picked:', random.choice(d[splitItems[1]])
print 'picked:', random.choice(d[splitItems[2]])
print 'picked:', random.choice(d[splitItems[3]])
print 'picked:', random.choice(d[splitItems[4]])

また、

SyntaxError on line 13;
    splitItems = items.split(',')

編集:間違いを修正

4

1 に答える 1

0

の最後に閉じ括弧がありません

items = raw_input("Pick 5 and separate them by a comma:" + ','.join(d)
于 2013-01-30T11:21:59.447 に答える