+ 1
How to get like this output????
using if statement i want syntax of if and elif If the first letter is A in our input it will select the A column if the first letter is B in our input it will select the B column sample output: ENTER YOUR NAME. : ABILASH YOUR ADJECTIVE NAME IS : ANGRY_ABILASH ENTER YOUR NAME. : BALAJI YOUR ADJECTIVE NAME IS : BOUNCER_BALAJI......
3 Answers
+ 1
thank u David Ashton davy hermans
+ 8
This?
name = input("ENTER YOUR NAME.: ").upper()
print(name)
if name[0] == "A":
print(f"YOUR ADJECTIVE NAME IS: {word}_ABLE")
elif name[0] == "B":
print(f"YOUR ADJECTIVE NAME IS: {word}_BIG")
elif name[0] == "C":
print(f"YOUR ADJECTIVE NAME IS: {word}_CRAZY")
elif name[0] == "D":
print(f"YOUR ADJECTIVE NAME IS: {word}_DARING")
But this is shorter:
words = [
"ABLE",
"BIG",
"CRAZY",
"DARING"
]
name = input("ENTER YOUR NAME.: ").upper()
print(name)
for word in words:
if word[0] == name[0]:
print(f"YOUR ADJECTIVE NAME IS: {word}_{name}")
You may have to format the input differently if this is homework 😉
+ 2
I guess you are looking for sometbing like this?
Inp = input().upper()
first = inp[0]
if first == "A":
print("blabla")
elif first == "B"
and so on