I need help Funtion sort a-z condition
Question:
Condition
Get input name 2 value
Get input first or last
if first print output name at meet before
if last print output name at meet after
example1:
input
name1 : Yudkon
name2 : Anon
choose : last
output
— Yudkon —
example2:
input
name1 : Somnamna
name2 : Somset
choose : first
output
— Somnamna —
Answers:
Hope you got the logic from my code below, if you have any questions, please ask them 😀
name1 = input("Name 1 : ")
name2 = input("Name 2 : ")
choose = input("Select first or last : ")
if choose == "first":
if name1 < name2: # check if name1 is in front of name2 (alphabetical)
print(name1)
else:
print(name2)
else:
if name1 > name2: # check if name1 is after name2 (alphabetical)
print(name1)
else:
print(name2)
Condition
Get input name 2 value
Get input first or last
if first print output name at meet before
if last print output name at meet after
example1:
input
name1 : Yudkon
name2 : Anon
choose : last
output
— Yudkon —
example2:
input
name1 : Somnamna
name2 : Somset
choose : first
output
— Somnamna —
Hope you got the logic from my code below, if you have any questions, please ask them 😀
name1 = input("Name 1 : ")
name2 = input("Name 2 : ")
choose = input("Select first or last : ")
if choose == "first":
if name1 < name2: # check if name1 is in front of name2 (alphabetical)
print(name1)
else:
print(name2)
else:
if name1 > name2: # check if name1 is after name2 (alphabetical)
print(name1)
else:
print(name2)