Python Forum
Taking Multiple Command Line Argument Input
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Taking Multiple Command Line Argument Input
#3
(Mar-29-2020, 03:32 PM)ndc85430 Wrote: Can you give examples of what you mean please (both input/output and code)? sys.argv already gives you a list of the arguments, so I don't know what you're splitting.

I have to write a command line argument so the user can write any number of inputs, number can change in every iteration up to user. I mean user can write 1 2 3 4 to the computer in first time she/he running the program but also can write 60 4 5 6 1 9 7 4
in another time.

a, b = input("Enter a two value: ").split()
print("First number is {} and second number is {}".format(a, b))
print()
This is the split example but there is a problem in here which is, the number of inputs are limited by the coder with 2. Which I don't want.

x, y, z = [int(x) for x in input("Enter three value: ").split()]
print("First Number is: ", x)
print("Second Number is: ", y)
print("Third Number is: ", z)
print()

This is an example of the other method an has the same problem, here the number of inputs are limited with 3.
Reply


Messages In This Thread
RE: Taking Multiple Command Line Argument Input - by bwdu - Mar-29-2020, 04:51 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Receive Input on Same Line? johnywhy 8 736 Jan-16-2024, 03:45 AM
Last Post: johnywhy
  __init__() got multiple values for argument 'schema' dawid294 4 2,414 Jan-03-2024, 09:42 AM
Last Post: buran
  problem in using input command akbarza 4 1,156 Oct-19-2023, 03:27 PM
Last Post: popejose
Information How to take url in telegram bot user input and put it as an argument in a function? askfriends 0 1,109 Dec-25-2022, 03:00 PM
Last Post: askfriends
  Trying to loop through code to plot seaborn line plots across multiple subplots eyavuz21 0 1,697 Dec-05-2022, 10:46 AM
Last Post: eyavuz21
  Command line argument issue space issue mg24 5 1,353 Oct-26-2022, 11:05 PM
Last Post: Yoriz
  accept command line argument mg24 5 1,350 Sep-27-2022, 05:58 PM
Last Post: snippsat
  Substitue multiple substrings in one command Pavel_47 0 843 Jul-18-2022, 01:24 PM
Last Post: Pavel_47
Lightbulb Multiple inputs on the same line (beginner) dementshuk 9 2,831 Sep-03-2021, 02:21 PM
Last Post: dementshuk
  Accessing varying command line arguements Rakshan 3 2,067 Jul-28-2021, 03:18 PM
Last Post: snippsat

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020