I'm new to Python and I cannot figure out how to use if statements and I'm growing desperate
Could someone with some more experience in the language help me out?
Here's the code I'm using
Code:# mOS Beta v0.1 help1 = HELP dir1 = DIR input("Enter Command: ") # HELP Command if(help1) print("Common Commands:\n") print("HELP - list common commands") print("DIR - open directory navigator") # Directory Manager elif(dir1) input("Specify Directory: ") in input("Select file or folder: ") in input("Select file or folder: ") in print("Opening file...") else print("Improper Command; Type [HELP] for a list of common commands") input()
Something like this? (See this for more information.)
Code:# Input a command into the variable 'command'
command = input('Enter a command: ')
# If 'command' = "help"
if command == 'help':
print('Commands available:\n\nhelp\ndir\n...')
# If 'command' = "dir"
elif command == 'dir':
print('You are in root directory.')
# Not a valid command
else:
print('Improper command - see help for complete list.')
Thank you. Unfortunately I can't test it now but when I get the chance I'll let you know how it goes
As for this:
I know that '\n' is the new line escape, but as for the rest, what is it?Code:\n\nhelp\ndir\n...
I've also seen that documentation, but I couldn't make heads or tails of that thing.
Nope. Didn't work.
Is that possibly Python 2.5 or 2.6?
Either way, Py3k is absolutely not backwards-compatible with and version of Python 2.
I've looked at the Python 3000 documentation and edited it to resemble the if statment example, yet still no dice. I'd post the current code, but I'm once again on my iPod.
Nope. Didn't work.
Is that possibly Python 2.5 or 2.6?
Either way, Py3k is absolutely not backwards-compatible with and version of Python 2.
I've looked at the Python 3000 documentation and edited it to resemble the if statment example, yet still no dice. I'd post the current code, but I'm once again on my iPod.
Last edited by WingedPanther; 02-11-2009 at 04:20 AM. Reason: Quadrupal posting
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks