#๐Ÿ”’ how do i take in a list of integers instead of a string of integers?

35 messages ยท Page 1 of 1 (latest)

undone ingot
#

My code works with string right now

thorny foxBOT
#

@undone ingot

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.

civic terrace
#

when they say "takes in a list of integers", they likely are referring to a function parameter

undone ingot
civic terrace
#

I don't really have enough information about how exactly they expect you to structure your code

#

I would create a function that accepts a list of ints as a parameter

#

how you arrive at that list really isn't important

#

You can test code without the need for input()

#

!e

def wave(nums):
    for num in nums:
        print('*' * num)


wave_nums = [1, 2, 3, 2, 1]
wave(wave_nums)
thorny foxBOT
#

@civic terrace :white_check_mark: Your 3.12 eval job has completed with return code 0.

001 | *
002 | **
003 | ***
004 | **
005 | *
undone ingot
#

this is how they test it

civic terrace
#

Then I was correct in what they expect of you

undone ingot
civic terrace
#

that was just so I could show you a test in action

#

a function simply says "give me some data and I'll do something with it"

#

it doesn't care where that data comes from

#

so you're meant to provide a function that can handle what they're asking of you

#

where it gets its numbers from is of no importance

#

you only need to write the function

#

it will handle the testing

#

(but it's still good to test your own function before submitting)

undone ingot
#

so if i want to submit without testing i can do this?

civic terrace
#

you shouldn't even call the function at the bottom

#

and you shouldn't need to do int(num) because they've already informed you that the provided list will contain ints

undone ingot
civic terrace
#

It will call it for you to test it

#

you don't need to call your own function to prove it works

#

the tests are responsible for that

undone ingot
#

oh ok

undone ingot
#

!close

thorny foxBOT
#
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.