Skip to content

Commit

Permalink
Create day-loops
Browse files Browse the repository at this point in the history
  • Loading branch information
kongkongo authored Jan 26, 2021
1 parent 0a5df0f commit c8f84ac
Showing 1 changed file with 78 additions and 0 deletions.
78 changes: 78 additions & 0 deletions day5-loops/day-loops
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
#loops循环

# count=0
# while count<5:
# print(count)
# count=count+1
# if count==3:
# break
# else :
# print(count)

#for循环
# numbers=[0,1,2,4,5,6,7]
# for number in numbers :
# print(number)

#example:For loop with string
# language = "Python"
# for letter in language:
# print(letter)
# example: For loop with tuple
# tuple_l = (0,1,2,3,4,5)
# for tuple_m in tuple_l:
# print(tuple_m)

#For loop with dictionary
# person={
# 'first_name':'Asabeneh',
# 'last_name':'Yetayeh',
# 'age':250,
# 'country':'Finland',
# 'is_marred':True,
# 'skills':["JavaScript",'React','Node','MongoDB','Python'],
# 'address':{
# 'street' : 'Space street',
# 'zipcode':'02210'
# }
# }
# for key in person:
# print(key)

# for key, value in person.items():
# print(key,':',value)

#For loop with set
# it_companies = {'Facebook','Goole','Microsoft', 'Apple', 'IBM', 'Oracle', 'Amazon'}
# for company in it_companies:
# print(company)


#Nested For Loop(嵌套循环)
# person={
# 'first_name': 'Asabeneh',
# 'last_name': 'Yetayeh',
# 'age': 250,
# 'country': 'Finland',
# 'is_marred': True,
# 'skills': ['JavaScript', 'React', 'Node', 'MongoDB', 'Python'],
# 'address': {
# 'street': 'Space street',
# 'zipcode': '02210'
# }
# }

# for key in person:
# if key == 'skills':
# for skill in person['skills']:
# print(skill)

#For Else
for number in range(11):
print(number)
else:
print('The loop stops at', number)

#pass
for number in range(6):
pass

0 comments on commit c8f84ac

Please sign in to comment.