Answer to Question #328762 in Python for Shubham Tiwari

Question #328762

Write a program to accept a tuple, extract the last string item of the tuple and return the string after removing the first character of the string.


1
Expert's answer
2022-04-15T16:36:33-0400
def last_str_from_tuple(tup):

	for el in tup[::-1]:
		if type(el)==str:
			return el[1:]
	return None

tup = ("a","abc", 123, [1,2,3], "python", 456)
print(last_str_from_tuple(tup))

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS