1/3
Learn this
Name | Mastery | Learn | Test | Matching | Spaced |
---|
No study sessions yet.
How can you split up words in an array?
Given this a array: ["Hello world!", "Hello there."]
You can use the .split() method to separate words in each string based on spaces or other delimiters.
array = ["Hello world!", "Hello there."]
for sentence in array:
words = sentence.split()
for word in words:
print(word)
How can you extract individual digits from a list of strings containing numbers?
Given this array: [12345, 67890]
You can access individual numbers by converting them to a string and iterating over them.
array = [12345, 67890]
for number in array:
for digit in str(number):
print(digit)
How can you reverse a string in Python?
string = "hello"
reversed_string = string[::-1]
print(reversed_string)
How to loop through an array starting from the end?
for element in range(len(array) - 1, -1, -1)
print(element)