import random
print ("
👥 Memorize
", end='')
pairs = ['🐇','🐈','🐒','🐋','🐎','🐍','🐢','🐝','🐂']
count = len(pairs)
nums = list(random.shuffle(pairs))\
.concat(list(random.shuffle(pairs)))
def mem_button(num):
button = document.createElement('button')
button.innerHTML = ' '
button.onclick = show(num)
return (button)
for num in nums:
document.body.appendChild(mem_button(num))
window.last_btn = Object()
def show(num):
return def():
button = this
button.innerHTML = num
if button==window.last_btn:
return
if window.last_btn.innerHTML==button.innerHTML:
button.disabled = True
window.last_btn.disabled = True
button.innerHTML=window.last_btn.innerHTML=num
window.last_btn = Object()
window.count = count - 1
if count==0:
win()
return
window.last_btn.innerHTML = ' '
window.last_btn = button
def win():
print('🏆')
print('Congratulations!
')
for b in document.getElementsByTagName('button'):
b.style.display = 'none'
print(''''''