Ask coding questions

← Back to all posts
how do you skip this?!?!?!??!??!
blackjkl (58)

so first you run this code. after you choose a or b, it says how far you want to generate. but if I type something other than the options, it still says "press g to generate". how do I skip that!?!??!?!

Answered by UniqueOstrich18 (236) [earned 5 cycles]
View Answer
Commentshotnewtop
UniqueOstrich18 (236)

Replace line 16 with:

  if generates == "far" or generates == "sort of far" or generates == "close": generate = input("press g to generate")

And replace line 37 with:

  if generates == "super far" or generates == "sort of super far" or generates == "far": generate = input("press g to generate")

If this was helpful, please mark this as the answer.

Also, please check out this (https://repl.it/talk/share/2048-In-Python/31140). I spent a ton of time making it.

Zexogon (835)

@blackjkl please do not spam in your own comments thanks -Dart

blackjkl (58)

plz give me ideas on random numbers 2

blackjkl (58)

plz give me ideas on random numbers 2

blackjkl (58)

plz give me ideas on random numbers 2 plz give me ideas on random numbers 2

blackjkl (58)

plz give me ideas on random numbers 2 plz give me ideas on random numbers 2 plz give me ideas on random numbers 2 plz give me ideas on random numbers 2

blackjkl (58)

plz give me ideas on random numbers 2

blackjkl (58)

wow first time I had 13 upvotes

blackjkl (58)

wow first time i had 10 upvotes

UniqueOstrich18 (236)

BTW, you quit() after invalid choice. Not only is it unnecessary, but it makes it look like an error. I recommend removing quit()

blackjkl (58)

@UniqueOstrich18 but it has an error:

Traceback (most recent call last):
File "main.py", line 9, in <module>
w
NameError: name 'w' is not defined

UniqueOstrich18 (236)

@blackjkl I'm not getting any errors.

UniqueOstrich18 (236)

@blackjkl But there's nothing on line 9.

blackjkl (58)

@UniqueOstrich18 no I mean the thing you want me to upvote

rediar (263)

@UniqueOstrich18 I don’t think your supposed to advertise your repl on other people’s posts..

blackjkl (58)

wow first time I had 7 upvotes.

blackjkl (58)

wow first time I had 6 upvotes

UniqueOstrich18 (236)

@blackjkl I bet you're gonna say, "wow first time I had 7 upvotes" after I upvote this post.

[deleted]

Instead of:

else:
  print(“invalid choice”)

do:

elif choice_random == not ((“a” or “A”) or (“b” or “b”)):
  print(“choice invalid”)

.
I’m not sure why, but it should work this way.

blackjkl (58)

@CodeABC123 sorry I didn't explain well enough. it's that on the second choice etc. (far/sort of far/close) or the other one, if I type something else other than the choices, how do I skip

generate = input("press g to generate")

[deleted]

@blackjkl Sorry, but I still don’t understand.

blackjkl (58)

@CodeABC123 so look:

I didn't choose a available option but it still says "press g to generate".

[deleted]

Oh. Then put

print(“Invalid”)
quit()

. @blackjkl

blackjkl (58)

@CodeABC123 but how does the computer know if it is an invalid choice?

[deleted]

Oh right.

if generates == not ((“far” or “sort of far”) or “close”):
   print(“invalid”)
   quit()

@blackjkl

blackjkl (58)

@CodeABC123 but it gives me an error

[deleted]

if -> elif @blackjkl

blackjkl (58)

wow first time I had 5 upvotes