Glaz
  • Political Ambassador
Badges: 22
Rep:
?
#1
Report Thread starter 1 week ago
#1
(Not sure if this is the right forum :ninja:)

I've got this program down in program, but it's saying there's an error and I have no idea how to fix it, can anyone help please?

Thanks!

(attaching the program)

EDIT: Just realised what the problem is :rolleyes:
EDIT 2: New problem, attaching again
EDIT 3: If you see two images attached, ignore the 2nd one, TSR isn't removing it :unimpressed:
EDIT 4: The correct attachment is Attachment 873986, not Screenshot 2020-01-15 at 12.20.03.png (124.8 KB) :ninja:


Attachment 873986
Attached files
Last edited by Glaz; 1 week ago
0
reply
mqb2766
Badges: 17
Rep:
?
#2
Report 1 week ago
#2
int() converts a string to a number (the 2 is a base). int("1",2) would work.
number isn't used in the program, so no idea why this line is here anyway?
0
reply
Glaz
  • Political Ambassador
Badges: 22
Rep:
?
#3
Report Thread starter 1 week ago
#3
(Original post by mqb2766)
int() converts a string to a number (the 2 is a base). int("1",2) would work.
number isn't used in the program, so no idea why this line is here anyway?
Okay, thanks! I removed that but it still isn't working

Name:  Screenshot 2020-01-15 at 13.14.24.png
Views: 9
Size:  125.2 KB
0
reply
Elsmok
Badges: 8
Rep:
?
#4
Report 1 week ago
#4
if reply == "1"
0
reply
Glaz
  • Political Ambassador
Badges: 22
Rep:
?
#5
Report Thread starter 1 week ago
#5
(Original post by Elsmok)
if reply == "1"
Name:  Screenshot 2020-01-15 at 13.21.31.png
Views: 5
Size:  120.2 KB

Then this happens :confused:
0
reply
Elsmok
Badges: 8
Rep:
?
#6
Report 1 week ago
#6
try putting "1" instead of 1
0
reply
Glaz
  • Political Ambassador
Badges: 22
Rep:
?
#7
Report Thread starter 1 week ago
#7
(Original post by Elsmok)
try putting "1" instead of 1
Ah, thanks a lot, that's perfect :hugs:
Also, how do I make it repeat itself, because if I don't type 1 or 2 then I can't do it again and have to restart:

Name:  Screenshot 2020-01-15 at 13.24.56.png
Views: 9
Size:  120.4 KB
0
reply
mqb2766
Badges: 17
Rep:
?
#8
Report 1 week ago
#8
(Original post by Glaz)
Ah, thanks a lot, that's perfect :hugs:
Also, how do I make it repeat itself, because if I don't type 1 or 2 then I can't do it again and have to restart:

Name:  Screenshot 2020-01-15 at 13.24.56.png
Views: 9
Size:  120.4 KB
What exactly do you want repeated?
0
reply
Glaz
  • Political Ambassador
Badges: 22
Rep:
?
#9
Report Thread starter 1 week ago
#9
(Original post by mqb2766)
What exactly do you want repeated?
Lines 5 through 15. As you can see in the screenshot, if I type a number that isn't 1 or 2, it won't ask again/let me type another number.
0
reply
mqb2766
Badges: 17
Rep:
?
#10
Report 1 week ago
#10
(Original post by Glaz)
Lines 5 through 15. As you can see in the screenshot, if I type a number that isn't 1 or 2, it won't ask again/let me type another number.
Why do you want the 1 or 2 repeated? Is this for another person or ....
Only asking because the loop is doing error checking, so if you want to enter multiple people or a single person with multiple valid ratings, you'd need two nested loops.
0
reply
Glaz
  • Political Ambassador
Badges: 22
Rep:
?
#11
Report Thread starter 1 week ago
#11
(Original post by mqb2766)
Why do you want the 1 or 2 repeated? Is this for another person or ....
Only asking because the loop is doing error checking, so if you want to enter multiple people or a single person with multiple valid ratings, you'd need two nested loops.
Well I've said that if the user enters "1", the system would reply "That's awesome!", and if the user enters "2", the system would reply "Awh, no, I'm sorry ". If the user doesn't enter 1 or 2, then the system will reply "You didn't type 1 or 2. Please try again!", but there isn't an option to retry.
I want after the system says "You didn't type 1 or 2. Please try again!" for it to allow you to put 1 or 2 again.
0
reply
Elsmok
Badges: 8
Rep:
?
#12
Report 1 week ago
#12
just remove flag = false on the last line as that is what is stopping the loop
0
reply
mqb2766
Badges: 17
Rep:
?
#13
Report 1 week ago
#13
(Original post by Glaz)
Well I've said that if the user enters "1", the system would reply "That's awesome!", and if the user enters "2", the system would reply "Awh, no, I'm sorry ". If the user doesn't enter 1 or 2, then the system will reply "You didn't type 1 or 2. Please try again!", but there isn't an option to retry.
I want after the system says "You didn't type 1 or 2. Please try again!" for it to allow you to put 1 or 2 again.
You'll probably need a "break" in the option 2 block as well.
0
reply
Glaz
  • Political Ambassador
Badges: 22
Rep:
?
#14
Report Thread starter 1 week ago
#14
(Original post by Elsmok)
just remove flag = false on the last line as that is what is stopping the loop
(Original post by mqb2766)
You'll probably need a "break" in the option 2 block as well.
Name:  Screenshot 2020-01-15 at 14.49.11.png
Views: 12
Size:  124.3 KB

Okay I've changed it to this, and it works and asks the question again, but after it asks the question again and I do type 1 or 2, it doesn't give the correct response
0
reply
Elsmok
Badges: 8
Rep:
?
#15
Report 1 week ago
#15
replace line 14 and 15 with

else:
reply = input("You didnt type 1 or 2. Please try again!")


EDIT:
If this doesnt work then recursion may be an option also
3
reply
Blue_Cow
Badges: 22
Rep:
?
#16
Report 1 week ago
#16
(Original post by Glaz)
Name:  Screenshot 2020-01-15 at 14.49.11.png
Views: 12
Size:  124.3 KB

Okay I've changed it to this, and it works and asks the question again, but after it asks the question again and I do type 1 or 2, it doesn't give the correct response
You are not storing the new value for the reply variable
0
reply
Glaz
  • Political Ambassador
Badges: 22
Rep:
?
#17
Report Thread starter 1 week ago
#17
(Original post by Elsmok)
replace line 14 and 15 with

else:
reply = input("You didnt type 1 or 2. Please try again!"


EDIT:
If this doesnt work then recursion may be an option also
Ah that works thanks so much :hugs:
0
reply
Glaz
  • Political Ambassador
Badges: 22
Rep:
?
#18
Report Thread starter 1 week ago
#18
(Original post by Blue_Cow)
You are not storing the new value for the reply variable
What does that mean :ninja:

Also btw I'm very new to all of this so sorry if I'm asking dumb questions
0
reply
Elsmok
Badges: 8
Rep:
?
#19
Report 1 week ago
#19
(Original post by Glaz)
Ah that works thanks so much :hugs:
no problem ask if u need anything else
0
reply
Glaz
  • Political Ambassador
Badges: 22
Rep:
?
#20
Report Thread starter 1 week ago
#20
(Original post by Elsmok)
no problem ask if u need anything else
Thanks
0
reply
X

Quick Reply

Attached files
Write a reply...
Reply
new posts
Back
to top
Latest
My Feed

See more of what you like on
The Student Room

You can personalise what you see on TSR. Tell us a little about yourself to get started.

Personalise

What's stopping you doing a masters?

It's too expensive (8)
25%
My career doesn't need one (3)
9.38%
I'm sick of studying (8)
25%
I can't find a course I want to do (1)
3.13%
I don't know enough about them (2)
6.25%
Nothing, I'm going to do it! (10)
31.25%

Watched Threads

View All