We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
hello,day07,scoretable.py,运行后5人成绩均为最后一人,或许5人的成绩list都为同一个引用。 将main()改为如下即可,如有更好办法请更新,我会继续学习,谢谢!
def main(): names = ['关羽', '张飞', '赵云', '马超', '黄忠'] subjs = ['语文', '数学', '英语']` scores = list() t_scores = [None]*3 for row, name in enumerate(names): print('请输入%s的成绩' % name) for col, subj in enumerate(subjs): t_scores[col] = float(input(subj + ': ')) scores.append(t_scores) print(scores) `
The text was updated successfully, but these errors were encountered:
def main(): names = ['关羽', '张飞', '赵云', '马超', '黄忠'] subjs = ['语文', '数学', '英语'] scores = [[0] * 3 for i in range(5)] for row, name in enumerate(names): print('请输入%s的成绩' % name) for col, subj in enumerate(subjs): scores[row][col] = float(input(subj + ': ')) print(scores)
Sorry, something went wrong.
No branches or pull requests
hello,day07,scoretable.py,运行后5人成绩均为最后一人,或许5人的成绩list都为同一个引用。
将main()改为如下即可,如有更好办法请更新,我会继续学习,谢谢!
The text was updated successfully, but these errors were encountered: