#๐Ÿ”’ If statement

70 messages ยท Page 1 of 1 (latest)

dusky lintel
#

How do i go from an if statement to another without the indent?

tiny brookBOT
#

@dusky lintel

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

dusky lintel
#

how do i go to another if statement

#

in order to input a second if

slate talon
#

Do you mean in the case where the current if is false

dusky lintel
#

yes

slate talon
#

Backspace

dusky lintel
#

it still gives ... instead of>>> on the side

#

i want >>> for the if statement

queen vault
#

are you not able to use an IDE?

dusky lintel
#

whats IDE (im new to programming

queen vault
#

It's for coding longer scripts

slate talon
#

If you want a totally separate if

queen vault
#

would you like an installation guide?

dusky lintel
#

i have to use idle

slate talon
#

Hit enter on the blank line

queen vault
#

I see

dusky lintel
#

its a school assignement

slate talon
dusky lintel
#

so idk

slate talon
#

Do you know what that means

dusky lintel
#

no

slate talon
#

Itโ€™s fairly self explanatory tbh

#

At least the last line

dusky lintel
slate talon
#

Whereโ€™s that from

#

!paste

tiny brookBOT
#
Pasting large amounts of code

If your code is too long to fit in a codeblock in Discord, you can paste your code here:
https://paste.pythondiscord.com/

After pasting your code, save it by clicking the Paste! button in the bottom left, or by pressing CTRL + S. After doing that, you will be navigated to the new paste's page. Copy the URL and post it here so others can see it.

dusky lintel
#

i wrote it before

errant temple
slate talon
#

what happens when you type
>>> age

pastel cradle
# dusky lintel

You shouldn't be using a REPL to write code. When you see >>>, you're in what's called a "REPL" (Read, Evaluate, Print, Loop). The purpose of REPLs is to run (usually) single lines of code at a time to see what happens. They are not meant for multiple writing multiple lines of code.

Go to File and then I think New File and create an actual file to write your code in. From there, you can press F5 to run the contents of the file. This has the benefit that it won't try to run the code every time you press enter.

slate talon
#

not meant for multiple lines of code? Iโ€™ve been doing repl wrong

pastel cradle
#

Well, not meant to write a lot of code. Usually, it's to run a small snippet, either to test a larger codebase, or run a line or two in isolation. If you want to write and execute multiple lines of code, saving the code to a file is usually easier unless you're using a notebook environment.

#

I have run multi-line statements in the standard Python REPL, but it is not ideal in my experience. I'll create an runnable fine pretty readily if I'm trying to run anything that spans multiple lines.

#

I should also mention, REPLs can be used for running pasted code that's many lines long, but that's not the case here.

tribal kelp
timber geyser
random field
#

I'm just gonna interject

#

If you're not familiar with the idea, you should be writing your code in an IDE - Integrated Development Environment

#

Which is a fancy way of saying "supercharged text editor designed specifically for code"

#

I mention this so I can expand on Carcigenicate's answer: there are very few instances where you'd actually want to write "live code." That is, if you see the ">>> " you're in an "interactive" coding environment. You don't want that

slate talon
#

so much REPL hate in this thread lol. it's great for learning. the environment wasn't his issue

random field
#

Not hate exactly XD Its just that you've got to use the right tool for the job

slate talon
#

prob just forgot he set "age" in a different instance

native plinth
#

they said "I have to use IDLE", which indicates they didn't really understand that the REPL can be running inside of IDLE, and that there is another option than the REPL

slate talon
#

yeah idk. i was just interested in seeing them work out the problem

#

but they abandoned us

native plinth
#

@dusky lintel are you working on doing the things that people have mentioned, or are you MIA?

dusky lintel
#

Iโ€™m just gonna ask the professor tomorrow, I think they will give us time in class to work on the problem

#

But idle is what we've been using the whole time

slate talon
native plinth
dusky lintel
#

Idk what MiA is

native plinth
#

Missing in Action

dusky lintel
#

Our school requires us to use idle

#

I took a pause on the problem

native plinth
#

they said "I have to use IDLE", which indicates they didn't really understand that the REPL can be running inside of IDLE, and that there is another option than the REPL

dusky lintel
#

I donโ€™t understand that statement

#

Whats another option than REPL

native plinth
#

there is the "IDLE Shell" which is the REPL. You can also edit files in IDLE

dusky lintel
#

Ok i ll try tomorrow thank you tho

native plinth
#

you write all the code, then you run all the code

tiny brookBOT
#
Python help channel closed for inactivity

This help channel has been closed. Feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.