#๐Ÿ”’ I need help with runtime error. I am a python beginner that is learning how functions work.

9 messages ยท Page 1 of 1 (latest)

lament cairn
#

Please help me if you can. Thank you.

    """Returns the artist and album name."""
    
    artist_and_album = {'artist': artist_name,
                        'album title': album_title,
                        'number of songs': num_of_songs}
    
    if num_of_songs:
        artist_and_album['number of songs'] = num_of_songs

    return (artist_and_album)

while True:
    print("Please type an artist name, album title, "
          "as well as number of songs.")
    print("Type 'quit' to stop. ")
    
    art_name = input("Artist: ")
    if art_name == 'quit':
        break    

    al_name = input("Album Title: ")
    if al_name == 'quit':
        break

    num_name = input("Number of Songs: ")
    if num_name == 'quit':
        break

info = make_info(art_name, al_name, num_name)
print(f"\nArtist: {info[art_name]}"
      f"\n Album: {info[al_name]}"
      f"\n Number of Songs: {info[num_name]}")
queen marshBOT
#

@lament cairn

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

#

Hey @lament cairn!

It looks like you pasted Python code without syntax highlighting.

Please use syntax highlighting to improve the legibility of your code and make it easier for us to help you.

To do this, use the following method:
```py
print('Hello, world!')
```

This will result in the following:

print('Hello, world!')```
You can **edit your original message** to correct your code block.
radiant osprey
#

!traceback What's the error?

queen marshBOT
#
Traceback

Please provide the full traceback for your exception in order to help us identify your issue.
While the last line of the error message tells us what kind of error you got,
the full traceback will tell us which line, and other critical information to solve your problem.
Please avoid screenshots so we can copy and paste parts of the message.

A full traceback could look like:

Traceback (most recent call last):
  File "my_file.py", line 5, in <module>
    add_three("6")
  File "my_file.py", line 2, in add_three
    a = num + 3
        ~~~~^~~
TypeError: can only concatenate str (not "int") to str

If the traceback is long, use our pastebin.

manic coral
#

First, it's possible to call a function with empty arguments in your code. Second, variable num_name is a string but integer expected. Third, you're using dictionaries wrong

#

when you type quit to exit the loop, it's used as a key to get dict value which doesn't exist

queen marshBOT
#
Python help channel closed

This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.