Python essay (c), Python basics

Source: Internet
Author: User

First, Practice:

#!usr/bin/env python
#-*-Coding:utf-8 _*-
"""
@author: Administrator
@file: dictionary.py
@time: 2017/11/19
"""
""
Have the following set [11,22,33,44,55,66,77,88,99,110,121,132,143,154,165,176,187], save all values greater than 66 in the first key of the dictionary, save the value less than 66 in the value of the second key
That is: {' K1 ': greater Than, ' K2 ': Less than 66}
‘‘‘
##### #方法一
#dic = {}
#all_list = [11,22,33,44,55,66,77,88,99,110,121,132,143,154,165,176,187]
#for I in All_list:
# If I > 66:
# if "K1" in Dic.keys ():
# dic["K1"].append (i)
# Else:
# dic[' K1 ' = [I,]
# Else:
# if "K2" in Dic.keys ():
# dic["K2"].append (i)
# Else:
# dic[' K2 ' = [I,]
#print (dic[' K1 ')
#print (dic[' K2 ')

#方法二,
All_list= [ One, A, -, -, -, the, the, the, About, the,121, the,143,154,165,176,187]
Dic= {' K1 ':[],' K2 ':[]}
forIteminchAll_list:
ifItem> the:
dic["K1"].append (item)
Else:
dic["K2"].append (item)
Print(dic[' K1 '])
Print(dic[' K2 '])


This article from the "Linux" blog, reproduced please contact the author!

Python essay (c), Python basics

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.