Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
数当てゲーム(全部自分で考えて書いた)
import random
oknumber = random.randint(1,10)
n = 1
print('1から10までの数を当ててください')
while oknumber != inputnumber:
inputnumber = int(input('数を入力してください:'))
if oknumber > inputnumber:
print('小さすぎます')
n += 1
elif oknumber < inputnumber:
print('大きすぎます')
n += 1
elif oknumber == inputnumber:
print('当たり!' + str(n) + '回で当てました!')
break
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.