Skip to content

Commit 6452ac2

Browse files
committed
add syntax highlighting
1 parent d3da374 commit 6452ac2

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

Day-2/README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@ Open the starter file: [silly sentence generator.py](silly sentence generator.py
1010

1111
Up until now, we've stored things in one variable at a time. A list is a way to collect multiple values in one variable. Let's make a list:
1212

13-
```
13+
```python
1414
>>> grocery_list = ["apples","bananas","a pet chicken"]
1515
```
1616

1717
We can look at specific items in the list with an *index*, and indexes start from zero.
1818

19-
```
19+
```python
2020
>>> print grocery_list[0]
2121
apples
2222
```
@@ -25,7 +25,7 @@ apples
2525

2626
We can use the random module to create random numbers:
2727

28-
```
28+
```python
2929
import random
3030
random.randint(0,5)
3131
```
@@ -35,7 +35,7 @@ A module is something extra in Python that lets you go beyond what Python lets y
3535
####The `random_word` Function
3636
The `random_word` function picks a random index from 0 to the last item in the list. Then, it finds the word with that index, and hands it back:
3737

38-
```
38+
```python
3939
#this function is given a list of words and selects one at random
4040
def random_word(list_of_words):
4141
number_of_words = len(list_of_words) #get the length of the words list
@@ -68,7 +68,7 @@ Be sure to insert the word "the" in the right places. What sentences can you ma
6868
####`random.choice`
6969
We just wrote a function to pick a random word from a list of words. However, the `random` module already gives us a way to do this. We can use `random.choice` to write a new version of `random_word`:
7070

71-
```
71+
```python
7272
def random_word2(list_of_words):
7373
return random.choice(list_of_words)
7474
```

0 commit comments

Comments
 (0)