forked from inspirezonetech/TeachMePythonLikeIm5
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlen.py
19 lines (16 loc) · 941 Bytes
/
len.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# ------------------------------------------------------------------------------------
# Tutorial: using the len built in function
# ------------------------------------------------------------------------------------
# len is used to find the amount of items in an object (ie an array)
array = ["1", "2", "3"]
# the len can be printed
print("The length of the array is: ", len(array))
# len can also be used to find the amount of characters in a string.
text = "text"
# the len can also be stored in a variable
textlen = len(text)
print("The amount of characters in the variable text is: ", textlen)
# ------------------------------------------------------------------------------------
# Challenge: 1. create an array with your own data and get the length of it.
# 2. create a program that checks the length of the string "Hello World!".
# ------------------------------------------------------------------------------------