forked from JobReadyProgrammer/PythonCourse
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathassignment_05.py
More file actions
66 lines (25 loc) · 745 Bytes
/
assignment_05.py
File metadata and controls
66 lines (25 loc) · 745 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# Assignment 5
"""
Define a method that accepts a list as an argument
and returns True if one of the first_folder 4 elements
in the list is a 6. The list length may be less than 4.
first3([1, 2, 6, 3, 4]) → True
first3([1, 2, 3, 4, 6]) → False
first3([1, 2, 3, 4, 5]) → False
"""
# Your Code Below:
print(first3([1,2,6,3,0,0])) # true
print(first3([1,2,3,3,0,6])) # false
print(first3([6])) # true
print(first3([])) # false
# Solution:
# def first3(numbers):
# # First figure the end for the loop
# end = len(numbers)
# if end > 4:
# end = 4
#
# for i in range(end): # loop over index [0, 1, 2, 3]
# if numbers[i] == 6:
# return True
# return False