Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a function in python called link_strings(xs): Consider a sequence of value

ID: 3693713 • Letter: W

Question

Write a function in python called link_strings(xs): Consider a sequence of values, xs. It can contain any python values, but we're only interested in the strings. Without using the type() function, just try concatenate each spot in the list to some sort of combined_string variable, and figure out how to pass over each failed (non-string) concatenation along the way.

Parameter: xs :: list of values.

Return value: a string as the concatenation of all strings in xs.

Requirement: you must use try-except blocks in your solution! Do not use type().

Examples:

o link_strings(['a','b','c']) 'abc'

o link_strings(['a','b',1,'c']) 'abc'

o link_strings([1,2,3]) ' '

Explanation / Answer

def link_strings(xs):
name=""

for ele inn xs:
if(!value_is_int(ele)):
name=name+ele
  
print name

def value_is_int(element):
try:
tempVal = int(value)
return True
except:
return False

xs=['abc','def','lmn']
link_strings(xs)

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote