+ 3
I have problems with pythons chatbot v1.1
I have done test case 1,but I don't know what to do with test case 2 and 3 because the difference between test case 1 and 2,3 is people's names and I don't know what to do with this
26 odpowiedzi
+ 9
It sounds like you're hardcoding. That means you can only solve 1 problem once.
You need to think of how you can solve all of the problems with the one code.
Review your lesson, are you accepting input? Or are you declaring the variable with a value?
For example:
Hardcoded
a = 2
b = 2
print(a+b)
You can only ever get the answer of "4"
Correct
a = int(input())
b = int(intput())
print(a+b)
Now, when the user types 2 numbers the program will display the answer.
Do you see the difference?
+ 7
Cloud ,
Share your attempted code...
+ 6
Your error is here:
# Take the name as input
name = "Mary"
It says to take the name as input. You don't accept input, you assign the value of the variable as "Mary". That's hardcoding.
Review the lessons and maybe my comment above.
+ 4
Surlax Mahat please don't spam with irrelevant comments.
You can share such things in your feed under the community tab.
+ 4
Can you share your code? (Read below)
That's as close as you'll get to a walk through.
https://code.sololearn.com/Wek0V1MyIR2r/?ref=app
+ 3
Thanks everyone, I solved the problem
+ 3
Read the comments here K. Bradley .
Do not hardcode "Mary", you need to accept an input.
+ 1
https://code.sololearn.com/c0RvC9DKkuQk/?ref=app
This is the code
+ 1
Ausgrindtube , thanks
+ 1
Share what you have tried so we can know where you have error.
+ 1
How did you do chatbot v1. 0?
+ 1
Sunday Ayomide you need to upload your code for us to see what's the problem.
Look at my post with the link to Ugulberto Sánchez's code.
0
I don't understand why the practice chatbot v1.1 doesn't get completed
0
I actually restarted introduction to python course (which I had completed long back) to see what is the code you were talking about. I am an old user of Sololearn. The code you shared didn't open for me.
Now coming to the question, you may have already performed string concatenation since your first test case passed. And I agree that you are hardcoding the name variable with the first test input value. Of course, the code would fail when that value changes for other test cases.
The name is a variable, not a constant. You hardcode constants, not variables (variable always varies in value).
So in this case, name is not only Maria, but also Tom and others depending on the testcase. It depends on the input, what the value of name should be. What is provided as input, needs to be the value of the name variable in this case. There is a way to store the input value in a variable, which was also discussed in the same lesson. Python provides an inbuilt function for storing inputs. Use that.
0
Hint: See Inputs and Outputs lesson in the same course if you are still confused
0
I actually restarted introduction to python course (which I had completed long back) to see what is the code you were talking about. I am an old user of Sololearn. The code you shared didn't open for me.
Now coming to the question, you may have already performed string concatenation since your first test case passed. And I agree that you are hardcoding the name variable with the first test input value. Of course, the code would fail when that value changes for other test cases.
The name is a variable, not a constant. You hardcode constants, not variables (variable always varies in value).
So in this case, name is not only Maria, but also Tom and others depending on the testcase. It depends on the input, what the value of name should be. What is provided as input, needs to be the value of the name variable in this case. There is a way to store the input value in a variable, which was also discussed in the same lesson. Python provides an inbuilt function for storing inputs. Use that.
0
Python has implictily changed the number as an integer due to some built in data types
0
I guess it would be great if the one asking the question has the option to lock the discussion when they have resolved their issue.
0
I am having issues with this and I cannot move past it I am getting the correct code for Mary but it is not generating the code for the other two people how do I get it to populate the correct code for all three people at the same time so I can pass onto the next lesson?
0
Ausgrindtube I've tried everything that makes sense on this post and so many ways. Is there a walkthrough somewhere? 😅