hey all I have been using batchfile scripting for a couple of years now and want to learn something else....python... this is so simple in batch but i cant make it work in python...help me out someone...
print " Python program"
print "************************************* "
print "(1) Open Internet Explorer"
print "(2) Open Firefox"
print "(3) Exit Program"
print "************************************* "what commands to i use and then go back to the start ?
I think.....num = raw_input ("what do you want to choose:") # is this right ?
if num == 1:
# i googled this stuff
import os
os.chdir ('C:\Program Files\Mozilla Firefox')
os.startfile ("firefox.exe")
# i googled this stuffif num == 2: # when second option do i use "ELIF" command ??
import os
os.chdir ("C:\Program Files\Internet Explorer")
os.startfile ("iexplore.exe")
if num == 3:
quit
else:
print "no selection made :P" # is this suppose to happen if i press enter without choosing ? cause it didnt do it for me...
now i have been reading everywhere to use "WHILE" command but the examples are for other things and i cant make it work for me in this ?
I would look for a "CASE" statement, I'm sure Python has one. I don't have the helpfile to check...
Python has no "case" or "switch" statement. The OP needs to use a series of "if else" statement within a "while TRUE" loop.
Ouch, that's what I get for assuming things. Since I screwed that up, here's pseudocode:
num=0
while num<>3 do: # or: while num !=3? you get the idea...
num = raw_input ("what do you want to choose:")
if num==1:
do ONE
end if # or whatever python uses to close a multi-command IF
if num==2:
do TWO
end if
loop
quitHad to give it a shot
Yes (14) | ![]() | |
No (14) | ![]() | |
I don't know (15) | ![]() |