Python Forum
I see is that sys.argv contains character strings
Thread Rating:
  • 1 Vote(s) - 1 Average
  • 1
  • 2
  • 3
  • 4
  • 5
I see is that sys.argv contains character strings
#1
from sys import argv
script, number1, number2 = argv
 
 
print("Here is your 1st number: ", number1)
print("Here is your 2nd number: ", number2)
product = number1 * number2
print(f"Here is your product: {product}")
number3 = int(input("Enter your number: "))
last_ans = number3 * product
print(f"Here is your final product times {number3}: ", last_ans)
Reply
#2
What is your question? Please edit the title and elaborate on the problem.
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#3
It's normal, that sys.argv is a list which contains strings, what else do you expect?
Just convert the strings to integer or float before using them for calculation.
product = int(number1) * int(number2)
Almost dead, but too lazy to die: https://sourceserver.info
All humans together. We don't need politicians!
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Trying to understand strings and lists of strings Konstantin23 2 764 Aug-06-2023, 11:42 AM
Last Post: deanhystad
  How do I call sys.argv list inside a function, from the CLI? billykid999 3 796 May-02-2023, 08:40 AM
Last Post: Gribouillis
  sys.argv method nngokturk 3 1,091 Jan-23-2023, 10:41 PM
Last Post: deanhystad
  Splitting strings in list of strings jesse68 3 1,773 Mar-02-2022, 05:15 PM
Last Post: DeaD_EyE
  [solved] unexpected character after line continuation character paul18fr 4 3,418 Jun-22-2021, 03:22 PM
Last Post: deanhystad
  import argv Scott 3 5,909 Apr-01-2021, 11:03 AM
Last Post: radix018
  SyntaxError: unexpected character after line continuation character siteshkumar 2 3,186 Jul-13-2020, 07:05 PM
Last Post: snippsat
  how can i handle "expected a character " type error , when I input no character vivekagrey 2 2,754 Jan-05-2020, 11:50 AM
Last Post: vivekagrey
  use of sys.argv deepakkr3110 3 3,054 Nov-29-2019, 05:41 AM
Last Post: buran
  Not all data returned from sys.argv ecdhyne 2 2,771 Sep-05-2019, 08:27 PM
Last Post: buran

Forum Jump:

User Panel Messages

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