Bryce DSA

0.0(0)
studied byStudied by 0 people
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/3

flashcard set

Earn XP

Description and Tags

Learn this

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

4 Terms

1
New cards

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)

2
New cards

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)

3
New cards

How can you reverse a string in Python?

string = "hello"
reversed_string = string[::-1]
print(reversed_string)

4
New cards

How to loop through an array starting from the end?

for element in range(len(array) - 1, -1, -1)
	print(element)