我被安排了5项任务,其中4项我已经完成了,但第5项是一场斗争这些任务是:
我已经做了4次了,但第5次我的代码是:
#Import Section
import random
import csv
import math
#Start Variables
Random_Words = []
alph = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
num = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26]
word_2 = []
#Foundation Code (List of words)
words = open('List_Words.txt')
first_10 = []
for line in words:
Random_Words.append(line[:-1])
#Making the random word
word = random.choice(Random_Words)
word = list(word)
#Making the random word into an alphabetical numeral
for character in word:
i = 0
while i < 26:
if character == alph[i]:
word_2.append(num[i])
i = i + 1
#print word
#print Random_word
print word_2
#Letting the person guess the word/ letter
guess_number = int(raw_input("choose a number: "))
guess_letter = raw_input("choose a letter: ")
i = word.index(guess_letter)
if word_2[i] == guess_number:
print "Correct"
else:
print "Nope"
相关问题 更多 >
编程相关推荐