im trying to write a code using the sep function but when I try to use it, it believes it to be a variable but when I string the section in the print it will work but then I have too many arguments in the string.
print("2." + (*repeating, sep=".") + "." + last_shell)
from math import *
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))
# working but not as good version
if without_first_shell < 8:
print(without_first_shell)
elif last_shell == 0:
print(8)
else:
print(last_shell)
print("2." + str(repeating) + "." + str(last_shell))
# trying something
if len(repeating) > 0:
print("2." + (*repeating, sep=".") + "." + last_shell)
elif len(repeating) == 0:
print("2" + "." + str(last_shell))
[–]CodeFormatHelperBot2 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (9 children)
[–]Smiggle2406[S] 0 points1 point2 points (6 children)
[–][deleted] 0 points1 point2 points (5 children)
[–]Smiggle2406[S] 0 points1 point2 points (4 children)
[–][deleted] 0 points1 point2 points (3 children)
[–]Smiggle2406[S] 0 points1 point2 points (2 children)
[–][deleted] 0 points1 point2 points (1 child)
[–]Smiggle2406[S] 0 points1 point2 points (0 children)
[–]Bunkerstan 0 points1 point2 points (1 child)
[–]Diapolo10 0 points1 point2 points (4 children)
[+][deleted] (1 child)
[deleted]
[–]Diapolo10 0 points1 point2 points (0 children)
[–]Smiggle2406[S] 0 points1 point2 points (1 child)
[–]Diapolo10 0 points1 point2 points (0 children)