#๐Ÿ”’ nested loops

58 messages ยท Page 1 of 1 (latest)

brittle cargoBOT
#

@topaz bloom

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.

wicked crown
#

so only the first [1-0] will work and others musnt work.
Can you elaborate on what you mean here? I'm not following.

lucid yarrow
#

does it have to be this complicated

rocky acorn
#

@wicked crown is this a thing: range(1-i)

#

i've always used a comma range(1,i)

wicked crown
rocky acorn
#

ah ok

#

do they know they're not using i2

lucid yarrow
#

i think yes

#

they could use and unders

rocky acorn
#

they mentioned letter C so makes me think they didn't share enough code

#

inverse of c?

#

where is c

wicked crown
#

I'm still confused about your question. Are you just asking why the prefix spaces happen on the second line and not the first?

rocky acorn
#

you printed out a star before you got to the inner loop

wicked crown
# topaz bloom yes

print prints a newline after. So after the first * is printed, print causes it to go to the next line, then the spaces are printed

#

So, on the first iteration of the outer loop, * is printed, the cursor moves down to the second line, then the prefix spaces are printed.

On the second iteration of the loop, the second * is printed after the prefix spaces that were added in the first iteration.

topaz bloom
rocky acorn
lucid yarrow
#

gg

topaz bloom
rocky acorn
#

you're trying to draw an ASCII C with asterisks * ?

topaz bloom
#

ASCII?

#

bro just normal C letter

#

with asteriks

rocky acorn
#

print('C')

topaz bloom
#

๐Ÿ˜„ ๐Ÿ˜„ ๐Ÿ˜„

#

each asterisk should look like asteriks not c. all of them should look like c made by asteriks

lucid yarrow
#

real

wicked crown
# topaz bloom ASCII?

They're referring to "ASCII Art". Meaning, making pictures out of characters you've arranged.

topaz bloom
#

thank you for information

#

answer: yes

rocky acorn
topaz bloom
#

yes

#

also possible

rocky acorn
#

well atleast we know what you're wanting to do now lol.. how to do it i dont know.. i asked an AI how to do it and im not allowed to share that answer with you so maybe someone else can take over and answer

topaz bloom
#

oh okay I asked it here instead of AI so maybe with one trick it would make it as I wanted. Thank you anyway.

wicked crown
#

Normally when doing ASCII art, you don't "generate" the characters. Normally, you see ASCII art just hardcoded in the code or in a separate file.

#

Unless you're doing it purely for the exercise.

topaz bloom
#

just to learn how nested loops work

wicked crown
#

I think you're going to have a real hard time just using nested loops for this as soon as you get to characters that have more detail than "C"

rocky acorn
#

yeah if you try to draw like a W with a nested loop, that's kinda insane

topaz bloom
#

hahahahah yes I am not gonna go that far because who would need it on real project

rocky acorn
#

i think Carcigenicate is saying most ppl do it like this:

print(" **** ")
print("*    *")
print("*     ")
print("*     ")
print("*    *")
print(" **** ")
wicked crown
#

Or just:

print("""
 ***
*
*
 ***
""")
topaz bloom
#

yeah

#

but then I cant learn nested loops

topaz bloom
wicked crown
#

I'd pick another way to practice. Working with grids often involve nested loops to go over the rows and columns. Conway's Game of Life is one of the first projects I do when I learn a new language because it covers stuff like this.

#

If you've never heard of it, Google it. They have a special page dedicated to it

topaz bloom
#

Ill check thank you it is great sharing. Im trying to be data analyst

#

I dont have any experience about any coding xd

rocky acorn
#

try drawing this with a nested loop for an exercise:

print("""
      February
                  1
2  3  4  5  6  7  8
9  10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28
""")
topaz bloom
#

thank you

brittle cargoBOT
#
Python help channel closed using Discord native close action

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.