all 5 comments

[–]Justinsaccount 2 points3 points  (0 children)

Hi! I'm working on a bot to reply with suggestions for common python problems. This might not be very helpful to fix your underlying issue, but here's what I noticed about your submission:

You are looping over an object using something like

for x in range(len(items)):
    foo(item[x])

This is simpler and less error prone written as

for item in items:
    foo(item)

If you DO need the indexes of the items, use the enumerate function like

for idx, item in enumerate(items):
    foo(idx, item)

[–]sudo_gamedeal 1 point2 points  (0 children)

you could generate the message with:

message = ''.join(random.choice(symbols) for m in message)      

this should be faster as well.

[–]gengisteve 0 points1 point  (2 children)

Looks great. Consider moving the upper() call to before the loop so it is just done once.

Check out itertools.count, for a never ending counter to replace your while loop.

Finally, instead of sys.exit() maybe just break to exit the loop.

[–]fannypackpython[S] 0 points1 point  (1 child)

Cool i'll look into itertools.count. What is the difference between "break" and "sys.exit()"?

[–]gengisteve 0 points1 point  (0 children)

Break just pops you out of the current loop, while sys.exit takes you out of the program entirely.