Put the entire contents of any given Py file in a def main():
. Otherwise you get errors:
Also I made a small mistake and since you are not using the function that I modified from InvisibleOne you should change line 1 to:
choice = int(input("Which file to run?\n1) calculator\n2) resume\n3) date_operation\n4) continueeven\n5) exeption1\n "))+1
Python starts counting at 0, so everything is 1 off. This accounts for that and fixes the problem.
1 Like
Aizki
February 17, 2023, 12:33pm
22
where do i define main? in the main.py or in the file im trying to open?
In every file you wish to open, put everything in that file in a def main():
(this will require indenting the whole thing) so that you can execute the file. I started doing this in the fork that I made, but I won’t do it for every one because I don’t have the time to and it’s your program. But look there to see how it’s done.
Aizki
February 17, 2023, 5:45pm
24
now its giving me this error
Literally everything must be indented. Use Ctrl A
to select all text and Ctrl ]
or Tab
to indent it. Then, add def main():
(not indented) to line 1.
print("Hello world!")
# Becomes:
def main():
print("Hello world!")
2 Likes
Aizki
February 17, 2023, 5:49pm
26
thank you, if i need help with anything ill ask you
1 Like
Huh, I never knew you could do that. That will come in handy later! I’ve always done one line at a time, which takes forever. Thanks!
@joecooldoo I also learned recently that Ctrl /
turns the line you’re on into a comment. Universal on Replit.
Aizki
February 17, 2023, 5:55pm
29
also do you have discord? if yes please send it
No I do not. You can always message me in Ask. Just click on my profile picture.
Aizki
February 17, 2023, 5:57pm
31
ok thank you if i need anything ill be sure to tell you
system
Closed
February 24, 2023, 5:58pm
32
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.