0

for example:

                        comm = raw_input("Type something you want to say to me > " )
                except: comm = "."

                if comm.lower().strip() == "hi":
                 print "hello"
(10% chance of running this command too) os.system('catimg devil_face.png')

here, catimg is a console command which turns images into ascii coloured characters, and devil_face.png is a scary image i uploaded to the machine.

Bunn E
  • 1
  • 1
    Can you clarify your question? Also, be careful about using a bare `except` like that, see https://stackoverflow.com/questions/54948548/what-is-wrong-with-using-a-bare-except. – AMC Mar 20 '20 at 00:33

1 Answers1

0

You can use the random library

import random
if random.randint(0, 10) == 0:
    print("only ten perecent chance of this happening")

random.randint picks a random number between two numbers. Since there is only a ten percent chance of it picking 0, it only had a ten percent chance of printing.

You can use this in your code before you use os.system, and put and if statment like this.

Hope this answers your question.