#๐Ÿ”’ how to get rid of \n in the output of my dictionary?

22 messages ยท Page 1 of 1 (latest)

lilac jetty
jovial ospreyBOT
#

@lilac jetty

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.

lilac jetty
#

the new line is still included in the values of my dictionary

#

the value to each key is a list but the new line is still present at the end of the list

#

can i get rid of that?

#

this is my desired output:

#

this is what im getting

#

i wanna remove the trailing stuff

jolly thicket
#

I believe there are module that parse csv

#

which usually in faster speed and less error

lilac jetty
#

im just trying to remove the \n at the end of every list

#

so it doesnt appear in the output of my dictionaryu

jolly thicket
#

list1[-1] = list1[-1].removesuffix('\n')

#

!d str.removesuffix

jovial ospreyBOT
#

str.removesuffix(suffix, /)```
If the string ends with the *suffix* string and that *suffix* is not empty, return `string[:-len(suffix)]`. Otherwise, return a copy of the original string:

```py
>>> 'MiscTests'.removesuffix('Tests')
'Misc'
>>> 'TmpDirMixin'.removesuffix('Tests')
'TmpDirMixin'
```   New in version 3.9.
lilac jetty
#

THANK YUOU

jolly thicket
#

!close

#

@lilac jetty

lilac jetty
#

!close

jovial ospreyBOT
#
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.