-1
percentage = (a+b+c+d)/4

print("Your final mark will be:", percentage,"%") 

Let's use 75 for example. 75 % shows as the output, but how do I make it so there's no space. Like 75% not 75 %.

Note: I tried using the + sign but it causes an error. Even shows an error when I try the .join() function. I have little experience with python, so I can't figure this out. I tried switching signs, spacing, removing the comma, placing the "%" outside, but keeps showing an error.

DjaouadNM
  • 22,013
  • 4
  • 33
  • 55
harold232
  • 119
  • 3

2 Answers2

1

This form of the print statement inserts a space separator; you have to circumvent the commas in your output list:

print("Your final mark will be:" + str(percentage) + "%")

Also look up how to do fancier output formatting; there are plenty of tutorials.

Prune
  • 76,765
  • 14
  • 60
  • 81
  • Good answer, i think using the .format function will be much preferred – 3NiGMa Sep 24 '19 at 23:20
  • Thanks. I posted as a nearly autonomous reaction, then realized that this *has* to be included in an earlier question. It's a "let me search that for you" issue. I'm leaving the answer here for OP's edification, but I expect this should be deleted within 24 hours. – Prune Sep 25 '19 at 00:14
0

Try replacing the last comma with a + sign, like so:

print("Your final mark will be",str(percentage)+'%')
3NiGMa
  • 545
  • 1
  • 9
  • 24
  • Thanks! By the way, do you know what the difference between using the + sign and the comma when separating stuff? Why can't I use both sometimes? – harold232 Sep 24 '19 at 23:14
  • The comma simply concatenates everything you add into a single string, with spaces in between, therefore you can use integers and float values when you concatenate them with the comma. The plus sign on the other hand, only connects string variables, and doesn't put anything in between them, so if you type `print('percentage ' + percentage')` it will return a `TypeError: can only concatenate str (not "int") to str` – 3NiGMa Sep 24 '19 at 23:18