#-*- coding:utf-8 -*-
school = {'1 class' : [172, 185, 193, 177, 196], '2 class' : [165, 173, 191, 189, 178]}
for class_number, students in school.items():
for student in students:
if student>190:
print(class_number), 'There are students who are over 190 in class.')
break
If you follow the example,
It comes out like this... I used utf-8 before that, but I don't know what's wrong here.
Is it the same problem when I read the json file?
python-2.x
You must use the python3
command to run Python3 on your Mac.
Try python3 code.py
.
Additional answers If you want to use it on Python2, you can do it like this.
# -*- coding: utf-8 -*-
school = {u"1 class": [172, 185, 193, 177, 196], u"2 class": [165, 173, 191, 189, 178]}
for class_number, students in school.items():
for student in students:
if student>190:
There are students over 190 in print(u"{}.format(class_number))
break
© 2024 OneMinuteCode. All rights reserved.