(Mar-25-2022, 04:50 PM)DeadlyKnight Wrote: How do I code its input without knowing it?
You may not know the name, but your program does: it is in the variable
input_1_5_1
(or one of the others ThiefOfTime proposed; just choose one). So you can open the file like this:
f = open(input_1_5_1, "w")
f.close() # Make a habit of it to close everything you opened once you are ready with it.
Oh I see, you put them in functions so the variables are local and not accessible for other functions. So get rid of the functions. Functions are only useful in the following cases:
- When you are building a large and complex program, you should split your program in parts that are not complex. These parts will be your functions.
- When you notice you have to copy parts of your code again and again because certain procedures have to be repeated, you had better put this part in a function.
- When your teacher requires you to use functions.
So if you need to use functions, then make sure these functions return the values you need again. And use parameters to provide these values to the function.