Sinisterly
My First Program Help! - Printable Version

+- Sinisterly (https://sinister.li)
+-- Forum: Coding (https://sinister.li/Forum-Coding)
+--- Forum: Python (https://sinister.li/Forum-Python)
+--- Thread: My First Program Help! (/Thread-My-First-Program-Help)



My First Program Help! - slither - 09-29-2015

So hi i was just wondering if its possible as i want to make a program where if the Input from the user was A then the screen clears and you can put whatever you want in it and save it this is what i have so far


#My random tool
Code:
print " " print "Welcome Nerd\n" def login(): usr = raw_input("Username: ") passw = raw_input("Password: ") if usr == "slither" and passw == "test": print "Success! You Have Logged In!" else: print "Login Failed Please Try Again!" login() print "" print "Type --help For Commands" print "" def whatNext(): next = raw_input("slither> ") if next == "--help": print " Use Can Use These Commands\n A For Inserting Text\n B For Inserting Files\n And C For Updates" elif next == "A": print "Need Help here!" # i dont know what to do next! whatNext()


thanks in advanced!


RE: My First Program Help! - Inori - 09-29-2015

if you're running windows, import os, then use os.system("cls"). Linux, os.system("clear"). If you're running it cross platform, you can use a ternary operator: os.system(["clear","cls"][os.name == "nt"]).

examples:
Code:
import os #1, Windows os.system("cls") #2, Linux/OSX os.system("clear") #3, cross platform os.system(["clear","cls"][os.name == "nt"])

Just a sidenote: you might want to write a method that gets the user information from a text file, like I did here using Ruby.


RE: My First Program Help! - slither - 09-30-2015

(09-29-2015, 10:44 PM)Gaige Wrote: if you're running windows, import os, then use os.system("cls"). Linux, os.system("clear"). If you're running it cross platform, you can use a ternary operator: os.system(["clear","cls"][os.name == "nt"]).

examples:
Code:
import os #1, Windows os.system("cls") #2, Linux/OSX os.system("clear") #3, cross platform os.system(["clear","cls"][os.name == "nt"])

Just a sidenote: you might want to write a method that gets the user information from a text file, like I did here using Ruby.

Thanks !