#๐Ÿ”’ need help with a task (new to coding)

12 messages ยท Page 1 of 1 (latest)

proud steppe
#

please help me with this problem

feral rivetBOT
#

@proud steppe

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.

proud steppe
#
def formatted (listen):
    sivert = []
    for item in listen:
        slittvert = ({item:.2f})
        sivert.append(str(slittvert))
    return sivert
print (formatted(0.333, 0.222))
#

its supposed to take a list of floating point numbers and then make them only have 2 decimals and then turn them into strings and return that

last lava
#

that {...} thing is supposed to go into an f-string

#

!f-string

feral rivetBOT
#
Format-strings

Creating a Python string with your variables using the + operator can be difficult to write and read. F-strings (format-strings) make it easy to insert values into a string. If you put an f in front of the first quote, you can then put Python expressions between curly braces in the string.

>>> snake = "pythons"
>>> number = 21
>>> f"There are {number * 2} {snake} on the plane."
"There are 42 pythons on the plane."

Note that even when you include an expression that isn't a string, like number * 2, Python will convert it to a string for you.

proud steppe
#

oh

proud steppe
#

!close

feral rivetBOT
#
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.