好的,我基本上已经创建了它,但仍然存在一些问题。
[更新] 我已经根据信息更新了它,但我又遇到了一些问题。
import random
print '|'*20
print '='*20
print 'Instruction'
print 'Enter high, low or quit!'
print 'Press enter without any input too see instruction'
print '='*20
print "="*5+'GAME START'+"="*5
print '='*20
print ''
card = [2,3,4,5,6,7,8,9,10]
choice = ' '
i=0
first = 1
while choice != 'quit':
card1, card2 = random.sample(card, 2)
showCard = [card1, card2]
startCard = card1
if choice == 'high':
if card1 > card2:
print ''
print str(card1) + ' first card1'
print str(card2) + ' first card2'
print ''
print 'wrong'
print ''
print 'Dealer Second card: '+str(card2)
print '-'*20
i=i+1
elif card1 <= card2:
print ''
print str(card1) + ' second card1'
print str(card2) + ' second card2'
print ''
print 'correct'
print ''
print 'Dealer Second card: '+str(card2)
print '-'*20
i=i+1
else:
print 'Dealer First card: '+str(card1)
elif choice == 'low':
if card1 > card2:
print 'wrong - testing 3'
print 'Next card: '+str(card2)
print '-'*20
else:
print 'correct - testing 4'
print 'Next card: '+str(card2)
print '-'*20
elif choice != 'high' or 'low' or 'info':
print 'Enter high or low only'
print 'First card 2: '+str(startCard)
choice = raw_input("Enter: ")
print i
print 'END'
输出:
====================
=====GAME START=====
====================
Enter high or low only
First card 2: 7
Enter: high
7 second card1
10 second card2
correct
Dealer Second card: 10
---------------------
First card2: 3
Enter: high
6 first card1
5 first card2
wrong
Dealer Second card: 5
问题:在第二个循环中,如何在“Enter:high”用户输入之前设置“6 first card1”?(将“第一卡2:3”替换为“6第一卡1”)
PS:先用高输入,因为低输入还在建设中
谢谢