Answers for "how to return first and last element in python"

1

how to take index first and last in python in one way

[some_list[0], some_list[-1]]
Posted by: Guest on January-04-2021
0

method get first last name python

def get_first_last_name(s):
    INVALID_NAME_PARTS = ["mr", "ms", "mrs",
    "dr", "jr", "sir"]
    parts = s.lower().replace(".","").strip().split()
    parts = [p for p in parts if p not in INVALID_NAME_PARTS]
    if len(parts) == 0:
        raise ValueError("Name %s is formatted wrong" %s)
    first,last = parts[0], parts[-1]
    first = first[0].upper() + first[1:]
    last = last[0].upper() + last[1:]
    
    return first, last
Posted by: Guest on January-07-2021

Code answers related to "how to return first and last element in python"

Python Answers by Framework

Browse Popular Code Answers by Language