table =
[['*', '*', '*', '*', '*'],
['*', '*', '*', '*', '*'],
['*', '*', '*', '*', '*'],
['*', '*', '*', '*', '*'],
['*', '*', '*', '*', '*']]
def print_table():
for row in range(5):
for col in range(5):
print table[row][col],
print ""
def clear_table():
for row in range(5):
for col in range(5):
table[row][col] = "*"
def table_has_letter(letter):
for letter in clear_table:
if letter in clear_table:
print true
else:
print false
这是我认为我错了
必须使用模块 (%)
def create_table(secret):
clear_table()
secret = secret.upper()
secret.replace(" ","")
secret.split(",")
for col in range(5):
row = 1
if len(secret) % 5:
row += 1
print [len(secret) % 5]
print secret[col]
create_table("mathematics")
print_table()
这是预期的:
P L A Y F
A I R * *
* * * * *
* * * * *
* * * * *