Bird
0
0

You want to print a list of items separated by commas but without spaces, like apple,banana,orange. Which code achieves this?

hard📝 Application Q8 of 15
Python - Input and Output
You want to print a list of items separated by commas but without spaces, like apple,banana,orange. Which code achieves this?
Aprint('apple, banana, orange')
Bprint('apple', 'banana', 'orange', sep=', ')
Cprint('apple' + ', ' + 'banana' + ', ' + 'orange')
Dprint('apple', 'banana', 'orange', sep=',')
Step-by-Step Solution
Solution:
  1. Step 1: Understand separator effect

    Using sep=',' joins arguments with commas without spaces.
  2. Step 2: Compare options

    print('apple', 'banana', 'orange', sep=',') prints 'apple,banana,orange'. print('apple', 'banana', 'orange', sep=', ') adds spaces after commas: 'apple, banana, orange'. print('apple, banana, orange') prints a single string with spaces. print('apple' + ', ' + 'banana' + ', ' + 'orange') concatenates with spaces after commas: 'apple, banana, orange'.
  3. Final Answer:

    print('apple', 'banana', 'orange', sep=',') -> Option D
  4. Quick Check:

    Use sep=',' for comma-separated without spaces [OK]
Quick Trick: Set sep=',' to join items without spaces [OK]
Common Mistakes:
MISTAKES
  • Using sep=', ' adds spaces
  • Printing single string literal
  • Concatenating manually unnecessarily

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Python Quizzes