-1

Here is my code:

def icecream():
    cost = int(6)
    flavor = input('What flavor would you like? => ')
    return 'The', flavor, 'will cost', cost, 'dollars.'

print(icecream())

then after printing the output i get is:

What flavor would you like? => ('The', 'Vanilla', 'will cost', 6, 'dollars?')

I want the output to just simply read:

What flavor would you like? => The Vanilla will cost 6 dollars.
tripleee
  • 175,061
  • 34
  • 275
  • 318

2 Answers2

2

When you return a comma-separated series of values, Python makes them into a tuple. The parenthesized output you see is that tuple.

If you want to do the equivalent of print('The', flavor, 'will cost', cost, 'dollars.'), where the individual items from the tuple are passed to the print function, you can do that with the * unpacking operator:

print(*icecream())

This is probably worse than formating a string, as the other answers suggest, but I thought it was worth including as an answer, since it seemed to me this was what you intended your current code to do.

Blckknght
  • 100,903
  • 11
  • 120
  • 169
0

Use fstring

return f'The {flavor} will cost {cost} dollars'