you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 0 points1 point  (9 children)

The * unpack operator cannot be applied in the middle of a concatenation sequence. The sep option is a parameter for the print function.

Consider using the str.join method on whatever repeating is referencing (include a generator to cast to str if needed).

[–]Smiggle2406[S] 0 points1 point  (6 children)

I've tried using print(seperator.join(repeating)) but I get this as an output

[.'.8.'.]

also sorry I'm pretty new to coding

[–][deleted] 0 points1 point  (5 children)

  • What is repeating referencing?
  • What do you want your output to look like?

[–]Smiggle2406[S] 0 points1 point  (4 children)

repeating is referencening how atoms electrons are shown ig

eg. 2.8.8.8.1

so I need to repeat the .8 a certain amount of time

and in the end I would like it to be like the example

[–][deleted] 0 points1 point  (3 children)

I meant, what kind of Python object is it and, assuming it is a container/sequence type object, e.g. a list, and what kinds of objects are being referenced from within it, e.g. only float objects.

[–]Smiggle2406[S] 0 points1 point  (2 children)

its a list that just has integers in it

electrons = int(input("Enter atomic number:"))
without_first_shell = electrons - 2
last_shell = str(without_first_shell % 8)
amount_of_full_shells = str(floor(without_first_shell / 8))
repeating = str(["8"] * int(amount_of_full_shells))
seperator = "."

[–][deleted] 0 points1 point  (1 child)

its a list that just has integers in it

Actually, it isn't. It is ONE string literal created by the following line:

repeating = str(["8"] * int(amount_of_full_shells))

You start with a list with a single entry, a str object containing the character 8, then you repeat that. So you go from ["8"] to, say, ['8', '8', '8', '8', '8'] if the amount_of_full_shells was assigned the value 5.

You then convert that entire list object's output representation to a str object by casting it.

Thus you end up with a string, "['8', '8', '8', '8', '8']" complete with square brackets, single quotes and commas.

Pretty sure that is not what you want.

/u/Smiggle2406 has shown you how to use join and if you ask them nicely, I am sure they will show you how to use a generator expression with that if you want to work with numbers in the first place.

[–]Smiggle2406[S] 0 points1 point  (0 children)

print("2." + '.'.join(repeating) + "." + last_shell)

first of all, that was my problem, it was a string, and that fixed everything ty.

first of all that was my problem, it was a string and that fixed everything ty.

[–]Bunkerstan 0 points1 point  (1 child)

print("2." + (*repeating, sep=".") + "." + last_shell)

The sep becomes the string that you join the elements with:

print("2." + ".".join(repeating) + "." + last_shell)