번호 옆에 기호가 있으면 가능한 난수가 생성 된 횟수를 표시하고 싶습니다. 그러나이 같은 숫자 아래에 새 줄에 기호를두고있다 :파이썬에서 난수 빈도 표시
Dice rolled:
You rolled 2 and 4
Roll again [y|n]? n
Number Frequency:
1
2
x
3
4
x
5
6
어떻게 그 숫자 옆에 같은 줄에 기호를 표시 할 수 있을까?
import random
diceCount = [0,0,0,0,0,0,0]
roll='y'
while roll=='y':
die1=random.randint(1,6)
die2=random.randint(1,6)
diceCount[die1] = diceCount[die1] + 1
diceCount[die2] = diceCount[die2] + 1
print('Dice rolled:')
print('You rolled',die1,'and',die2)
if roll=='y':
roll=input('\nRoll again [y|n]? ')
while roll!='y' and roll!='n':
roll=input("Please enter either 'y' or 'n': ")
if roll=='n':
print('\nFace Freqeuncy:')
index=1
while (index<len(diceCount)):
print(index)
for number in range (diceCount[index]):
print(' x')
index+=1
이것은 OP 도움이되지 않습니다. 카운트되지 않은 모든 값은 동일한 행에있게됩니다. –