Hello I'm very new to Python and having some issues with understanding tuples. This code below gets this error: "TypeError: can only concatenate tuple (not "str") to tuple"
Any idea the best way to do this? The code is supposed to take out only strings from the tuple "t" and then put them in a new tuple together.
Cheers!
t = 1, 43.2, 'this is a string', 'what?','hello'
t_new = tuple()
for item in t:
if isinstance(item, str):
new_tuple_item = item
t_new = t_new + new_tuple_item
print('The filtered tuple is', t_new)