|
15 | 15 | verb = ["drove", "jumped", "ran", "walked", "skipped"] |
16 | 16 | preposition = ["to", "from", "over", "under", "on"] |
17 | 17 |
|
| 18 | +def random_int(): |
| 19 | + return random.randint(0,4) |
18 | 20 |
|
19 | 21 | def random_sentence(): |
20 | 22 | """Creates random and return sentences.""" |
21 | | - |
22 | | - sentence = "" |
23 | | - sentence += article[random.randint(0, 4)] + " " + noun[random.randint( |
24 | | - 0, 4)] + " " |
25 | | - sentence += verb[random.randint(0, 4)] + " " + preposition[random.randint( |
26 | | - 0, 4)] + " " |
27 | | - sentence += article[random.randint(0, 4)] + " " + noun[random.randint( |
28 | | - 0, 4)] + ". " |
29 | | - sentence = sentence[0].upper() + sentence[1:] |
30 | | - |
31 | | - return sentence |
32 | | - |
33 | | - |
| 23 | + return ("{} {} {} {} {} {}" |
| 24 | + .format(article[random_int()] |
| 25 | + ,noun[random_int()] |
| 26 | + ,verb[random_int()] |
| 27 | + ,preposition[random_int()] |
| 28 | + , article[random_int()] |
| 29 | + ,noun[random_int()])).capitalize() |
| 30 | + |
34 | 31 | # prints random sentences |
| 32 | +map(lambda x: print(random_sentence()), range(0, 20)) |
35 | 33 | for x in range(20): |
36 | 34 | print(random_sentence()) |
37 | 35 |
|
38 | | -print() |
39 | | -print() |
| 36 | +print("\n") |
40 | 37 |
|
41 | | -# creates short story |
42 | | -story = "" |
43 | | -for x in range(20): |
44 | | - story += random_sentence() |
| 38 | +story = (". ").join(list(map(lambda x: random_sentence(), range(0, 20)))) |
45 | 39 |
|
46 | | -print(story) |
| 40 | +# prints random sentences story |
| 41 | +print("{}".format(story)) |
0 commit comments