Python Forum
SyntaxError: positional argument follows keyword argument
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
SyntaxError: positional argument follows keyword argument
#1
Hello All,

I am trying to do four simple things:
1. Prompt user for input,
2. Store user entered input in variable,
3. Repeat 1 and 2,
4. Add the values stored in two variables and output/display the result.

I know the following works:
print("Enter the first number:", end = ' ')
first = int(input())
print("Enter the second number:", end = ' ')
second = int(input())
print("The answer is:", first + second)
BUT I want to do it all on a single line, like below - is this even possible?
print("Enter another number:", end = ' ', third = int(input()), "And another number:", end = ' ', fourth = int(input()), "The answer is:", third + fourth)
When I try the single line, I get
Quote:SyntaxError: positional argument follows keyword argument
error message.

I am using Python3.8.1
Reply


Messages In This Thread
SyntaxError: positional argument follows keyword argument - by syd_jat - Feb-23-2020, 11:47 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  501 Server cannot accept argument anna17 0 183 Apr-11-2024, 01:08 AM
Last Post: anna17
  Django "Unexpected Keyword Argument 'min_value'" AstralWeeks 0 213 Mar-27-2024, 04:56 AM
Last Post: AstralWeeks
  File is not being created with 'w' argument CAD79 3 430 Mar-14-2024, 12:05 PM
Last Post: snippsat
  __init__() got multiple values for argument 'schema' dawid294 4 2,315 Jan-03-2024, 09:42 AM
Last Post: buran
  mutable argument in function definition akbarza 1 478 Dec-15-2023, 02:00 PM
Last Post: deanhystad
  Find a specific keyword after another keyword and change the output sgtmcc 5 817 Oct-05-2023, 07:41 PM
Last Post: deanhystad
  Strange argument count error rowan_bradley 3 718 Aug-06-2023, 10:58 AM
Last Post: rowan_bradley
  Invalid argument: 'images\x08ackground.jpg' CatBall 4 962 Jun-19-2023, 09:28 AM
Last Post: CatBall
Information How to take url in telegram bot user input and put it as an argument in a function? askfriends 0 1,087 Dec-25-2022, 03:00 PM
Last Post: askfriends
  i want to use type= as a function/method keyword argument Skaperen 9 1,859 Nov-06-2022, 04:28 AM
Last Post: Skaperen

Forum Jump:

User Panel Messages

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