Python Forum

Full Version: My .exe made using Python being detected as a virus
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I am currently trying to make simple code that misspells a word and copies it to your clipboard but when I share it to another computer it is detected by antivirus as a trojan. Is there anything I can do to prevent this from happening?
Here is my code:

import random
import pyperclip

filler = []
valid = False


def charGen(x):
    if x == 6:
        return "b"
    elif x == 5:
        return "a"
    elif x == 4:
        return "n"
    elif x == 3:
        return "a"
    elif x == 2:
        return "n"
    elif x == 1:
        return "a"


while not valid:
    word = "b"
    filler = []

    length = random.randint(3, 7)

    word = word + charGen((random.choice([4, 5])))

    for a in range(length):
        filler.append(charGen(random.randint(1, 6)))
        word += filler[a]

    word = word + "a"

    if word.find('n') >= 0:
        print(word)
        valid = True

    for b in range(len(word)-1):
        if word[b] == word [b+1]:
            valid = False
pyperclip.copy(word)
(tbh, the reason the charGen function has so many repeating words is because it was originally intended for another word)
you can simplify charGen:
def charGen(x):
    ret="banana"
    if x > 0 and x < len(ret)+1:
        return ret[x-1]

print(charGen(5))
print(charGen(2))
print(charGen(7))
print(charGen(0))
Output:
n a None None