![]() It will take all the individual letters that it can be iterated through and create a new string separating them. You could have used a ',' and left it without a space even.Ġ2:34 Great! So one kind of interesting thing to think about is that any string is an iterable also, so if you had a string of just a word-and let’s say that word is 'lobster', and right now, what type is 'lobster'? It’s a string. It’s a single string, again, joined together using this separator. Let’s try it with ours, mylist,Ġ2:21 and see what returns. So this will be returned as a new string. So here, you can see the example’s showing joining this list together. join() is one of them.Ġ2:07 And you can see that it’ll concatenate any number of strings. And since it’s a string, you can see all the methods that are there, and. That’s your separator, which is a string. join() works with those iterables.Ġ1:54 In this case, you can give it a separator-in this case, maybe we’ll use, I don’t know, let’s try a semicolon and a space. Make sure to open and close each string object with a single quote ( ') or double quote ( ") and place a comma ( ,) in between the objects.Ġ1:44 Now that you’ve created mylist-and you can check its type, it is the - how can you use the method. To start, I’ll have you create a list.Ġ1:29 A list is contained within square brackets. It concatenates strings from that iterable. Again, as a note, I’ll also include more information about lists and tuples below this video.Ġ1:15 The first method you’re going to try is. ![]() Whereas a tuple, also sometimes pronounced “tup-ple”, is enclosed within parentheses and is immutable.Ġ1:00 This is very quick introduction on these topics, but you need to know a little bit about what they look like for this next set of methods and their examples. Many of these methods return either a list or a tuple, which are very similar collections of ordered objects, but they have a couple of differences.Ġ0:47 A list is enclosed within square brackets and it’s mutable, meaning that the contents can change. Iterating, or walking through, all the members of a collection is a common technique done inside of Python.Ġ0:33 I will include links below this video for more information about Python iterables. Iterable is a general Python term for a sequential collection of objects. The methods that are in this group convert between a string and some composite data type by either pasting objects together to make a string or by breaking a string apart into its pieces.Ġ0:16 These methods operate on or return iterables. 00:00 For this last video on string methods, I’m going to show you a little bit about converting between strings and lists. ![]()
0 Comments
Leave a Reply. |