0

I want to use the following code so that when I run the exe file in CMD, I enter the name of my program, for example the number 2 or 3, and my code creates a file, otherwise it gives me the value "no" no no" but every time I run it, it gives me the following error

import sys

def test(numder):
    x =numder
    if x ==2:
        open("E:\myfile1.txt", "2")
        return "myfile1 crated"
    elif x ==3:
        open("E:\myfile2.txt", "3")
        return "myfile2 crated"
    return "no no no "

n= int(sys.argv[1])
print("n is: ",n)
x=test(n)
print(x)

enter image description here

Navrang
  • 41
  • 4

0 Answers0