Menu

[solved]-1 String Called Batman Contains Full Name Everyone S Favorite Caped Crusader Want Display Q39084852

1) We have a string called batman which contains the full nameof everyone’s favorite caped crusader. We want to display only hismiddle name.

Use string slicing to slice his middle name from the originalbatman string.

Do not do this: print(“Anthony”) — use stringslicing!

When you are finished, your output will match the DesiredOutput.

# Create /batman/ variable
batman = “Bruce Anthony Wayne”

# Print the middle name using
# string slicing
desired output:

Anthony

2) We have a string called batman which contains the full nameof everyone’s favorite caped crusader. We want to find out if hisname contains the letter “f”.

Complete the conditional statement which checks whether “f” isfound within the string called batman.   When youcomplete it, the output will match Desired Output.

# Create /batman/ variable
batman = “Bruce Anthony Wayne”

# Check if the letter “f” is
# in the string /batman/
if :
print(“We found an ‘f’!”)
else:
print(“There is no ‘f’ in this name”)

desired output:

There is no ‘f’ in this name

3) Split the string quote into individual words using thesplit() method, then print the result. When you are finished, youroutput will match the output under Desired Output.

# Create my_string
quote = “Hello, my name is Inigo Montoya”

# Step 1: Split /quote/ into individual words

# Step 2: Print the results
desired output:

[‘Hello,’, ‘my’, ‘name’, ‘is’, ‘Inigo’, ‘Montoya’]

4)Split the string quote into individual words using the split()method, then print the result. When you are finished, your outputwill match the output under Desired Output.

# Create my_string
quote = “Hello, my name is Inigo Montoya”

# Step 1: Split /quote/ into individual words

# Step 2: Print the results
desired output:

[‘Hello,’, ‘my’, ‘name’, ‘is’, ‘Inigo’, ‘Montoya’]

Expert Answer


Answer to 1) We have a string called batman which contains the full name of everyone’s favorite caped crusader. We want to display… . . .

OR


Leave a Reply

Your email address will not be published. Required fields are marked *