Ask coding questions

← Back to all posts
PLEASE HELP ME (Python)
TROD2007 (2)

Please help me, i'm trying to make it so when someone types something, it will pop something up. But idk how to. I think I have the simple stuff but I need help pls.

Answered by Bookie0 (4977) [earned 5 cycles]
View Answer
Commentshotnewtop
Bookie0 (4977)

btw you have an error on line 3:
instead of:

prin/.t("There are four math games. The four are addition, subraction, division, and multiplication")

do:

print("There are four math games. The four are addition, subraction, division, and multiplication")

;)

TROD2007 (2)

@Bookie0 yeah, I see that, I can fix that, but Im confused with how the command stuff isn't working. When I fix the print it shows red all over the command statements.

19wintersp (286)

@TROD2007 That's because command isn't defined. You need to do something like command = input() before the ifs for it to work.

Bookie0 (4977)

@TROD2007 yea, you have to define command. You probably want an input, so on line 6 you could add something like:

command = input("Enter operator ")
TROD2007 (2)

@19wintersp ohhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh thank you thank you thank you

TROD2007 (2)

@Bookie0 hello, can you help me with something else please?

TROD2007 (2)

@19wintersp hello, can you help me with something else please?

TROD2007 (2)

@19wintersp thank you for helping me

TROD2007 (2)

@19wintersp so in the code, it show if command and elif command statments, but im tryin to make it so that way after it prints easy, medium, or hard it goes somewhere. The main thing is how do I add more command statements after the other command statements and the print

Bookie0 (4977)

@TROD2007 you can add more command statements by adding more conditionals (elif)s

TROD2007 (2)

@19wintersp if you don't get what I am writing look at the code and look at the error, how do I make it correct?

Bookie0 (4977)

@TROD2007 also if you want it to go "somewhere" after it prints "easy, medium, or hard", just add more code in the conditional branch; ie: in the same indentation as print("Ok, which difficulty do you want to practice in? \nEasy \nMedium \nHard") ;)

TROD2007 (2)

@Bookie0 hi, on the code, how do I keep the command where it is but make it correct?

TROD2007 (2)

@Bookie0 i think ur gonna have to put that in english, im still a noob

19wintersp (286)

@TROD2007 Two things are immediately wrong. First of all, Python is complaining that the elif is out of line with the print on line 10. Secondly, elif must come after an if statement.

TROD2007 (2)

@Bookie0 like i don't know what the branch stuff is cuz i dumb and noob

Bookie0 (4977)

@TROD2007 atm I'm a bit busy, invite me to a repl, and I'll take a look at it later :)

TROD2007 (2)

@Bookie0 do I just give you the url? if so then here it is...
https://repl.it/@TROD2007/Fun-Math#main.py
if not then how?

TROD2007 (2)

@19wintersp but then how do I make it correct?

TROD2007 (2)

@Bookie0 ok, thank you for helping me, ill try to make all the chatting things correct so you can get over 5000 :)

19wintersp (286)

@TROD2007 You invite with the "share" button in the top-right.

19wintersp (286)

@TROD2007 Realign the elif on line 8 to be in line with the print above it, and change it from elif to just if.

TROD2007 (2)

@19wintersp also, I invited you to the repl thingy

TROD2007 (2)

@19wintersp YAY, it works thank you very much

TROD2007 (2)

@Bookie0 Hi, sry I just need a little help pls. To the repl i invited you to earlier.

Bookie0 (4977)

sure, I'm kinda busy these days, but I'll try to come at a moment. In the meantime you can put comments explaining the code and what's wrong! :D @TROD2007

TROD2007 (2)

@Bookie0 ok, its fine, just come when you can. So I am just trying to make something where you can't beat it. so whenever you put rock, it puts paper and whenever you put paper it puts scissors and when you put scissors, it puts rock.

Bookie0 (4977)

@TROD2007 ok I'll try to help you with that on the repl

Bookie0 (4977)

@TROD2007
aight I added some code, should work now! Lemme know if you have any other problems/comments! :D

TROD2007 (2)

@Bookie0 thank you! I was confusuled

TROD2007 (2)

@19wintersp hey, im making a new repl and it's going to be stories. so if you are curious and wanting to let out some stories, just come on in. the name is top secret so join. and I mean literally, its name is top secret

TROD2007 (2)

@19wintersp hi, can you help me pls

TROD2007 (2)

@19wintersp hey winter, I just need some help on something, here is the link, pls help as soon as possible
https://repl.it/@TROD2007/MASH

ElanRodriguez3 (9)

ok i guess this is a still-in-progress thingy

TROD2007 (2)

@firedragondnd thats pretty cool, but mine is going to be like practice worksheet, not a calculator, but that's really cool

TROD2007 (2)

Hey guys and girls, I need help with another thingy please?

TROD2007 (2)

How is it looking so far? Is there anything I should change?

TROD2007 (2)

You know like in other games where you input something and then it take you to another screen and practically deletes everything else.how do I do that cuz I want to make it so that way when they input what thing they want to do and what difficulty they want, it takes them to another page and starts showing the problems

TROD2007 (2)

Hello again, I have one more question

TROD2007 (2)

Thank you everyone for helping me with the game. I greatly appreciate it ======))))))))))

Squirrel777 (89)

Ohhhhh, just do:

command = input("Which one do you want to do?")
Bookie0 (4977)

Hey,

Please precise what you mean by "pop something up". Do you mean that you want something to appear when the user is typing with an input for example?

Bookie0 (4977)

@TROD2007 don't think that's possible, since when you display the input, nothing will happen till after the user presses enter. An alternative to input would be getch.getch():

import getch

print("Enter your name")
age = getch.getch() # asks for age, user doesn't have to press enter at the end contrary to input

print(age)
Bookie0 (4977)

@TROD2007 cool, is this what you wanted?

Bookie0 (4977)

@TROD2007 sure, remember to mark this answer as correct if it helped! ;)

TROD2007 (2)

@Bookie0 how many cycle things did you get?

Bookie0 (4977)

@TROD2007 how many cycles I have? uh it says so in the paranthesis if you wanna know

TROD2007 (2)

@Bookie0 ohhhhh you have 4453!!!!!!!!

Squirrel777 (89)

Just change the prin/.t to print?

TROD2007 (2)

@Squirrel777 no i did that so that way it only shows red there so i can read the other stuff, when im done i can change that, but thx

Squirrel777 (89)

@TROD2007 Ok, but what do you mean by "Pop something up"? Like alert() in Javascript?

TROD2007 (2)

@Squirrel777 no, im writing this game in python, and i mean pop something up like a command statment for example when someone put yes when a game says do you want to play again, it starts over

Squirrel777 (89)

@TROD2007 Oh! You mean input. Its called input, not command statement. And just use this code:

#Fun Math Repl
while True:
  print("Hello, this is the fun math game thingy. Try it out and have fun!")
  print("There are four math games. The four are addition, subraction, division, and multiplication")
  print("Put which one you want to practice...")
  print("\n1. Multiplication \n2. Division \n3. Addition \n4. Subtraction")

  command = input("\nEnter what you want to practice: ")

  if command == "Multiplication":
    print("Ok, which difficulty do you want to practice in?")
  if command == "Division":
    print("Ok, which difficulty do you want to practice in?")
  if command == "Addition":
    print("Ok, which difficulty do you want to practice in?")
  if command == "Subtraction":
    print("Ok, which difficulty do you want to practice in?")

If you have any questions, let me know!

TROD2007 (2)

@Squirrel777 ok thank you. do you want to be friends?

19wintersp (286)

What do you mean by "pop something up"?

TROD2007 (2)

@19wintersp like when they say help, it pops some writing up that shows th instructions

TROD2007 (2)

@19wintersp do you know the command statements?

19wintersp (286)

@TROD2007 print() and input() should suffice for console I/O in Python. If you want to read user input, you could do something like command = input("What command? ")