-2

I'm using Python, and I want to ask a user for input to define a variable, then ask for another input using what they inputted into the first question as part of the second question.

That might be confusing. I mean like this:

hometeam = str(input("Home team?"))
ppg = input(hometeam "Average Points per Game?")
print(ppg)

For example, if the user inputs "Cowboys" for hometeam, I'd like the program to ask "Cowboys Average Points per Game?" for the second question.

I'm getting a syntax error with a carrot pointing at the last quotation mark.

1
  • The duplicate should provide more than enough examples how to properly interpolate strings in Python. Commented Oct 12, 2017 at 19:52

2 Answers 2

1

You saved that input into the variable "hometeam", so you can do something like this using "+":

ppg = input(hometeam + " Average Points per Game?")

Sign up to request clarification or add additional context in comments.

Comments

0
hometeam = str(input("Home team?"))
ppg = input("{0} Average Points per Game?".format(hometeam))
print(ppg)

2 Comments

You probably want to have a whitespace: " Average Points per Game?"
Thanks, updated answer.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.