Question
Hi, I have a question about Python. I don't have any experience in Python as I've only really ever coded in mostly C++ or C,
Hi, I have a question about Python. I don't have any experience in Python as I've only really ever coded in mostly C++ or C, and I'm confused about how to read a string from a printed statement. For example, if I print out a statement as follows: print(Home = + getHome(car, 45, mercedes)), I understand that this would call on the function getHome and do whatever that function tells the program to do. My question is, what do I do to be able to read those three words within the brackets and print out what is needed. Like for above, how would I be able to "read" that there is car in between the first quotations (anything can go in between these parentheses so how would i read the word in there), the numbers after the comma, and then the word within the next quotations. Here is an example using the above statement with a sort of psuedocode:
print(Home = + getHome(car, 45, mercedes))
def getHome
read the words and numbers within the parentheses
if (first word = car)
{
print("statement")
}
else if (second number > 40 || < 60)
{
print("statement")
}
else if (third word = mercedes)
{
print("statement")
}
I don't need an exact code or anything that needs to run, I more just want an explanation on how to read those statements and print out what is needed accordingly. I will be sure to rate if I find the answer helpful. Thank you!
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started