Why the following code is giving me output as none. Basically, I attempt to get the output as Lastname Firstname.
So I used split() so that it will return me the list and then I tried to reverse the list using reverse()
.
Though I'm getting output as none.
CODE:
fn="FirstName LastName".split(" ")
a=fn.reverse()
print(a)
list.reverse()
changes list "in-place", so your a
variable is None
.
Try:
fn = "FirstName LastName".split(" ")
fn.reverse()
print(" ".join(fn))
Prints:
LastName FirstName