#๐Ÿ”’ Begginer

47 messages ยท Page 1 of 1 (latest)

timid cypressBOT
#

@abstract arrow

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.

dapper wraith
#

!code

timid cypressBOT
#
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.

dapper wraith
#

as told

abstract arrow
#

how do i do that

spring tiger
#

npty wants you to paste in what code you have so far, between ```py and ``` code fence lines.

boreal trench
#

you also used wrong symbols

#

that's a backtick `

#

not a quote '

dapper wraith
#

You put the link that generated if you used pastebin

spring tiger
abstract arrow
#

my bad guys this is my first time doing this

#

there we go

spring tiger
#

Ta.

#

So, what do you need to know?

abstract arrow
#

ok so i know some of the basics not all of them

dapper wraith
#

first, do you know how to split according to space?

abstract arrow
#

idk how to split the names so i recieve only the initials

dapper wraith
#

follow me step by step

abstract arrow
#

ok

spring tiger
#

That takes 2 steps: split the string up, and then take the first character from each substring.

dapper wraith
abstract arrow
#

no

spring tiger
#

!doc str.split

timid cypressBOT
#

str.split(sep=None, maxsplit=-1)```
Return a list of the words in the string, using *sep* as the delimiter string. If *maxsplit* is given, at most *maxsplit* splits are done (thus, the list will have at most `maxsplit+1` elements). If *maxsplit* is not specified or `-1`, then there is no limit on the number of splits (all possible splits are made).

If *sep* is given, consecutive delimiters are not grouped together and are deemed to delimit empty strings (for example, `'1,,2'.split(',')` returns `['1', '', '2']`). The *sep* argument may consist of multiple characters as a single delimiter (to split with multiple delimiters, use [`re.split()`](https://docs.python.org/3/library/re.html#re.split)). Splitting an empty string with a specified separator returns `['']`.

For example:
spring tiger
#

Your full_name variable contains a string, so it has a .split() method (because it's a string, type str).

abstract arrow
#

ok im following

dapper wraith
#

so, what would you do after reading that?

spring tiger
#

Got an interactive prompt handy? The >>> prompt for Python's interactive mode?

abstract arrow
#

after every first letter split it from the rest? right?

dapper wraith
#

you split the entire input to a list of word, and get the initial for each item from the list

abstract arrow
#

oh ok

#

so im splitting each name individually right

dapper wraith
# timid cypress

you learn this on how to seperate a string to a list of sub-string

abstract arrow
#

no i didnt

#

i don't think the textbook went over that

#

so im kind of lost on that part

dapper wraith
#

we on't know what you learnt

#

but we just taught you this

#

we couldn't guess what you have learnt

abstract arrow
#

so after each space am i splitting the names up?

dapper wraith
#

you either tell us what you have learn, or we would suggest you to use that that we have taught you

abstract arrow
#

for example if i were to use this would it work py name_parts = full_name.split()

dapper wraith
#

yes

abstract arrow
#

oh ok ok

timid cypressBOT
#
Python help channel closed using Discord native close action

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.