#๐Ÿ”’ its called for loops

35 messages ยท Page 1 of 1 (latest)

vivid vortex
#

in_count = int(input())
name_list = []
for i in range(in_count):
name_list.append(input())

print(f'List has {in_count} elements:')

''' Your code goes here '''

this is the code and it wants me to do this ive tried a buch but none is working could i get some help pls

Integer in_count is read from input representing the number of values to be read next. The remaining values are read from input into name_list. For each value in name_list, output the value followed by ' verified' on the same line.

astral hazelBOT
#

@vivid vortex

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.

vivid vortex
strong steeple
#

What problem are you having?

vivid vortex
#

let me see if i can get it to show again

hybrid cosmos
# vivid vortex

ok, what have you tried so far? how would you approach this problem?

vivid vortex
strong steeple
#

Ah, it looks like you're missing part of what the problem is asking you to solve

#

See how it says Your output: xxxx and then Expected output: xxxxx + some highlighted stuff?

hybrid cosmos
# vivid vortex

looks like they're already giving you the list and you only have to loop over it

strong steeple
#

the highlighted stuff is what you're missing

vivid vortex
#

this is what it gives me for help but im not doing very good with this lesson how would i put this into code

hybrid cosmos
astral hazelBOT
#
Formatting code on Discord

Here's how to format Python code on Discord:

```py
print('Hello world!')
```

These are backticks, not quotes. Check this out if you can't find the backtick key.

For long code samples, you can use our pastebin.

strong steeple
#

It wants you to wrap your code in 3 backticks

vivid vortex
#
in_count = int(input())
name_list = []
for i in range(in_count):
    name_list.append(input())

print(f'List has {in_count} elements:')
in_count = int(input())

name_list = []
for _ in range(in_count):
    name = input()
    name_list.append(name)

for name in name_list:
    print(name + ' verified')
hybrid cosmos
#

you know why i did that?

vivid vortex
#

no

hybrid cosmos
# vivid vortex no

because you already have name_list and are appending to it in lines 1-4

#

so you don't have to repeat the exact same code again

vivid vortex
#

oh i put it twice

#

omg i was just puting the list twitce lol ty for the help

strong steeple
#

haha yeah, it happens. For your understanding too, when you did this

in_count = int(input())
name_list = []
for i in range(in_count):
    name_list.append(input())

print(f'List has {in_count} elements:')
in_count = int(input())

name_list = []

Specifically

name_list = []

You actually overwrote the original namelist that took in the values with nothing

astral hazelBOT
#

Hey @strong steeple!

It looks like you pasted Python code without syntax highlighting.

Please use syntax highlighting to improve the legibility of your code and make it easier for us to help you.

To do this, use the following method:
```py
print('Hello, world!')
```

This will result in the following:

print('Hello, world!')```
You can **edit your original message** to correct your code block.
strong steeple
#

I did wrap it D:

#

haha yeah, it happens. For your understanding too, when you did this

name_list = []
for i in range(in_count):
    name_list.append(input())

print(f'List has {in_count} elements:')
in_count = int(input())

name_list = []

Specifically

You actually overwrote the original name_list that took in the values with nothing

#

there we go

#

Does that make sense @vivid vortex ?

vivid vortex
#

yes thank you

strong steeple
#

Sweet, np

astral hazelBOT
#
Python help channel closed

This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, 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.