Okay so I know what the problem is. The thing about the numbers 10 and 39 is that they all contain 1, 2, 3 which are the goods numbers of playing video games. The code is only looking for those characters, it doesn't care if there is another number attached to it. So, how do we fix this? A simple fix is to look for not only the number, but the space after it, because that means it isn't attached to another number. This does mean the user can still say something like "play games 3 8 hours", but let's be honest, we only care about the first number, so this isn't something to get a headache over.
My code:
elif "play" in inp: if "video" in inp \ or "games" in inp: if "hours" in inp: if "3 " in inp \ or "2 " in inp \ or "1 " in inp: increaseSocialCredit(120) else: decreaseSocialCredit(1200)
(I am new and I don't know how to format)
Okay so I know what the problem is. The thing about the numbers 10 and 39 is that they all contain 1, 2, 3 which are the goods numbers of playing video games. The code is only looking for those characters, it doesn't care if there is another number attached to it. So, how do we fix this? A simple fix is to look for not only the number, but the space after it, because that means it isn't attached to another number. This does mean the user can still say something like "play games 3 8 hours", but let's be honest, we only care about the first number, so this isn't something to get a headache over. My code:
elif "play" in inp: if "video" in inp \ or "games" in inp: if "hours" in inp: if "3 " in inp \ or "2 " in inp \ or "1 " in inp: increaseSocialCredit(120) else: decreaseSocialCredit(1200)
(I am new and I don't know how to format)