Ask coding questions

← Back to all posts
My program won't run!
AbdulQurashi (2)

Please correct my code:

Number = int(input("Enter a number"))
step2 = print("now double your number", Number)
step3 = int(input(step2))

if step3 == Number * 2:
step4 = int(input("Now add 4"))
else:
print("You are incorrect, please try again")

if step4 == step3 + 4:
step5 = int(input("Now halve your number"))
else:
print("You are incorect, please try again")

if step5 == step4 / 2:
step6 = int(
input("Now substract the number you have now from your first number",
Number))
else:
print("You are incorrect, please try again")

if step6 == step5 - Number:
print("Your number is 2")
else:
print("You are incorrect, please try again")

Answered by heyitsmarcus (282) [earned 5 cycles]
View Answer
Commentshotnewtop
heyitsmarcus (282)

To fix the program, I just really added a "quit()" line after any incorrect guesses in the path. You don't want a user to continue if the math wasn't correct. And then, I just formatted it just a bit nicer.

Please upvote if I was helpful =]

Here is the new REPL: https://repl.it/@heyitsmarcus/GraveAquamarineRoutes

AbdulQurashi (2)

@heyitsmarcus
Thanks a lot, it worked perfectly and looked way nicer.

heyitsmarcus (282)

@AbdulQurashi You are most welcome! It will come together for you soon, and you'll be making awesome programs! :)

MATTHEWBECHTEL (121)

Hey. I’m actually useful. I fixed your code @AbdulQurashi https://repl.it/@MATTHEWBECHTEL/dollariskejskekd
Turns out you just need to learn to indent. Btw please Upvote my comment if it works for you now

katyadee (1084)

@MATTHEWBECHTEL Hey there, this isn't very nice :/ Please be respectful when answering questions. Everyone's at a different place in their journey.

MATTHEWBECHTEL (121)

When I said they’re error was indenting you thought it wasn’t nice? If so, I didn’t mean it like that. I meant I saw a common error for python users which was indenting. @katyadee

AbdulQurashi (2)

@MATTHEWBECHTEL
When I ran your program it still never worked:
Enter a number6
now double your number 6
None12
Now add 416
Now halve your number8
Traceback (most recent call last):
File "main.py", line 17, in <module>
Number))
TypeError: input expected at most 1 arguments, got 2

Thanks for trying though.

MATTHEWBECHTEL (121)

Have you defined your variables? I think I saw that you did but I’m not sure if you did them correctly.

MATTHEWBECHTEL (121)

I’m not the best programmer but lemme have the link and I’ll fork and run it. @AbdulQurashi