#๐ nested loops
58 messages ยท Page 1 of 1 (latest)
@topaz bloom
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.
so only the first [1-0] will work and others musnt work.
Can you elaborate on what you mean here? I'm not following.
does it have to be this complicated
That's just math. range(1 - 2) is the same thing as range(-1)
they mentioned letter C so makes me think they didn't share enough code
inverse of c?
where is c
I'm still confused about your question. Are you just asking why the prefix spaces happen on the second line and not the first?
yes
you printed out a star before you got to the inner loop
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.
so how do you reccomend ?
what do you want the end result to look like?
thank you so much
gg
normal C
you're trying to draw an ASCII C with asterisks * ?
print('C')
๐ ๐ ๐
each asterisk should look like asteriks not c. all of them should look like c made by asteriks
real
They're referring to "ASCII Art". Meaning, making pictures out of characters you've arranged.
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
oh okay I asked it here instead of AI so maybe with one trick it would make it as I wanted. Thank you anyway.
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.
just to learn how nested loops work
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"
yeah if you try to draw like a W with a nested loop, that's kinda insane
hahahahah yes I am not gonna go that far because who would need it on real project
i think Carcigenicate is saying most ppl do it like this:
print(" **** ")
print("* *")
print("* ")
print("* ")
print("* *")
print(" **** ")
Or just:
print("""
***
*
*
***
""")
this helps me a lot but still I will spend some time on it to get this nested thing...
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
Ill check thank you it is great sharing. Im trying to be data analyst
I dont have any experience about any coding xd
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
""")
thank you
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.