Leo Umesh avatar

PASSING USER INPUT FROM COMMAND PROMPT IN PYTHON

leoumesh

Published: 05 Aug 2020 › Updated: 05 Aug 2020PASSING USER INPUT FROM COMMAND PROMPT IN PYTHON

PASSING USER INPUT FROM COMMAND PROMPT IN PYTHON

2.png

I have this simple python code saved in my desktop in the folder named as "Python".

1.png

You can see I run the file named "Running_from_cmd.py" from the command prompt. And it shows the correct output. What if I want to pass the input from cmd and the cmd or the IDE shows the output. So for that we have to pass the arguments to the same command line as shown below:

4.png

The code in the IDE should be this:

3.png

argv stands for Argument values and here I have passed the index value of 1 because index value 0 indicates the file name which is Running_from_cmd.py in the command line. 6 is the index value 1 and 4 is the index value 2. The same value passes to the IDE and the output is shown accordingly.

Leave PASSING USER INPUT FROM COMMAND PROMPT IN PYTHON to:

Written by

I am just a passionate blogger.

Read more #hive-114105 posts


Best Posts From Leo Umesh

We have not curated any of leoumesh's posts yet. But you can encourage our curation team to review posts by visiting them regularly and by referring other readers. Because we give priority to frequently read content.

More Posts From Leo Umesh