-
Notifications
You must be signed in to change notification settings - Fork 0
/
pizza_slicer_starter.py
66 lines (24 loc) · 1.16 KB
/
pizza_slicer_starter.py
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
# Pizza Slicer
# Demonstrates string slicing
# To slice, use the format [ starting index value : ending index value : step]
word = 'pizza'
# Note: A slice will always occur to the LEFT of the index value given if
# slicing forwards; occurs to the RIGHT if slicing backwards.
# slicing shorthand
# we can omit values in a slice to represent the start and end of a word
print(
'''
Slicing 'Cheat Sheets':
FORWARDS: BACKWARDS:
0 1 2 3 4 5 0 1 2 3 4
+---+---+---+---+---+ +---+---+---+---+---+
| p | i | z | z | a | | p | i | z | z | a |
+---+---+---+---+---+ +---+---+---+---+---+
-5 -4 -3 -2 -1 -6 -5 -4 -3 -2 -1
''')
# CHALLENGE: Write a program that allows the user to slice the word 'pizza'
# as many times as they want by getting the beginning and ending
# index values for the slice.
word = 'pizza'
print ("Enter the beginning and ending index for your slice of 'pizza'...")
input('\n\nPress the enter key to exit.')