Ask coding questions

← Back to all posts
can i not put all these in one line
hayyita (0)

another thing i wanted to ask:

can i not put all of these in one line? I'm trying to get all of this info from the same key but it doesn't work if i put more than 1 on each line like this

Comments
hotnewtop
Coder100 (16991)

1. Variable

Make sure you aren't trying to access something that is inside a function or in other words something that is not in the same 'indentation' as your string.

2. Yeah sure

print("no newline", end='')
RYANTADIPARTHI (6000)

Solution

You need to give the dict name. try this code.

kq = [
    {"name": "ateez",
    "number": "8", 
    "members": "hongjoong, seonghwa, yunho, yeosang, san, mingi, wooyoung, jongho",
    "slogan": "8 makes 1 team",}
]

print(f" group {kq['name']} has {kq['number']} members.Their names are {kq['members']} and their team slogan is {kq[slogan]}.")

like that
That should work

IntellectualGuy (686)

@RYANTADIPARTHI You have an extra comma, and it would be like kq[0], because you are surrounding it in a list