def Complicated_Greetings(name): # using the orignial logic to make it more readable. h=["H","e","l","l","o"] c="," w=["W","o","r","l","d"] e="!" k="" # build each term hello= ''.join(h) #create string from list comma= ' ' if name else c+ ' ' #whitespace, or comma plus whitespace world= ''.join(w) if not name else "" #create string from list or nothing name= name if name else '' #name or nothing exclamation= e* 2 if not name else "" #two exclamations or nothing return hello+ comma+ world+ name+ exclamation #build the final string and return it
- def Complicated_Greetings(name):
- # using the orignial logic to make it more readable.
- h=["H","e","l","l","o"]
- c=","
- w=["W","o","r","l","d"]
- e="!"
- k=""
for i in h:k+=iif name=="":k+=ck+=" "for i in w:k+=ik=k+e+eelse:k+=" "k+=namereturn k- # build each term
- hello= ''.join(h) #create string from list
- comma= ' ' if name else c+ ' ' #whitespace, or comma plus whitespace
- world= ''.join(w) if not name else "" #create string from list or nothing
- name= name if name else '' #name or nothing
- exclamation= e* 2 if not name else "" #two exclamations or nothing
- return hello+ comma+ world+ name+ exclamation #build the final string and return it