How can you count the times a specific character shows up in a string
counter = string.count(char_of_intrest)
If wanting to use an if statement for when a character of interest is present in a string?
if char_of_interest in string:
Syntax when a character of interest is not present?
while strong not in (“characters of intrest “)
How to make it so that in a loop it checks for the characters in a string
for i in string:
syntax of the last item in a string ?
string[-1]
How to split a string?
line = input().split()
line=string.split()
How to split a list ?
1st = [“apple pie”, “chocolate bar”]
split_list = [item.split() for item in lst]
print(split_list)
# [[‘apple’, ‘pie’], [‘chocolate’, ‘bar’]]
how to get a random integer
random.randint()
if needing to break a phrases into looking for the presence of a specific variable
letter of interest input
phrases=input()
first- create a list of strings through splitting the phrases
words= phrases.split()
for word in words:
if letter in word:
print(f’found {letter} in {word}’)