Share your repls and programming experiences

← Back to all posts
Poetry Program
HenryZelonka1 (18)

This is a program a found in an old coding book. The program was written in BASIC but I translated it to python. It generates a random poem. I made the words that are random display in blue and the default words in white.

It may give you an error message. If it does, just restart the program. It will eventually work.

Here is an example of a poem generated.


Commentshotnewtop
CodingCactus (2126)

why are you trying to use the list like b[d][e] that is only for 2d arrays, here you are using a 1d array, therefore you should just use b[e]

CodingCactus (2126)

also, lists start at index 0, so you should do something like e = randint(0, len(b)) or something

HenryZelonka1 (18)

You're right. I'll fix it.

HenryZelonka1 (18)

I know it sometimes gives an error message, but it does work. I think there must be some error in the way the IDE processes lists, because sometimes it works and sometimes id doesn't.

CodingCactus (2126)

@HenryZelonka1 a list is always the same, if there is an error, then it is your code that has an error, not the ide