Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Why does it matter where my: print num_ly(1900,2000)is located? I thought once we wrote it that we could call on it anywhere in out #code?
- #for example, this works:
- def num_ly(year1, year2):
- n = 0
- while year1 < year2:
- print year1
- if isleap(year1):
- n = n + 1
- print n
- year1 = year1 +1
- def isleap(year1):
- return year1 % 4 == 0 and (year1 % 100 != 0 or year1 % 400 == 0)
- print num_ly(1900,2000)
- #but this doesn't:
- def num_ly(year1, year2):
- n = 0
- while year1 < year2:
- print year1
- if isleap(year1):
- n = n + 1
- print n
- year1 = year1 +1
- print num_ly(1900,2000)
- def isleap(year1):
- return year1 % 4 == 0 and (year1 % 100 != 0 or year1 % 400 == 0)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement