Execute statement for python.

I think 'def something()' is the only way to define something as just a placeholder in python, please correct me if im wrong.
 
By the way, dont ask me to correct you because I am much more rubbish than you at python.
(the main reason I posted this is to get 100 posts)
 
ok, taking your advice, I made an update to my app but whenever I type 'cal', instead of executing, it says: <built-in function input>!

here is my updated code:


Code:
# This is a project by zak and shuaib.

print ("----------[START PAGE]----------")

print ("Welcome to zak and shuaib's pre-alpha stage command prompt!")
print ("Type 'helpone' for a list of commands!!!")
 
# This shows the 'helpone' command:

helpone=" cal=calculator app (this is still in production and the command wont work), ver=show software version. There will loads more commands soon remember this is just a test stage"

if input == "helpone":
 print (helpone)

# Here is the 'ver' command:

ver= ("zak's and shuaib's command prompt version: v0.1.3")

# This shows all of the app commands:

# Here is the calculator app:

cal=input

if input == "cal":
 exec(open("./Calculator.py").read())
 
Last edited by a moderator:
ok, taking your advice, I made an update to my app but whenever I type 'cal', instead of executing, it says: <built-in function input>!

here is my updated code:


Code:
# Here is the calculator app:

cal=input

if input == "cal":
 exec(open("./Calculator.py").read())

You're calling input twice.

You only need to get your input once.

i.e.

Code:
commandInput = input('Enter your desired command: ')

if commandInput == "cal" 
  ''' calculator logic  here
else if commandInput == "ping"
  ''' ping logic here
...etc

BTW, when posting code... please use code tags ;). Makes it easier to read that way.
 
Last edited:
Back
Top Bottom