Ask coding questions

← Back to all posts
yall, i think im overthinking this, but i need help
Dominicl645 (428)

so i am having to do this:
Write the code to multiply the numbers 1 through 7.
The output should look like: 1x2x3x4x5x6x7 = 5040
remember you can use end in print to print items on the same line
You will need to use a for loop with range
You will need to create a variable called total and initialize it to 1 not 0
Use range to print the first half of spellList
spellList = ["Wednesday", "Tuesday", "February", "November", "Annual", "Calendar", "Solstice"]
You will need to use len() to help find the middle of the list

and i am trying to work with it, but i am not getting the results it says im supposed to get. Any advice or help? @Coder100
it i wasnt stuck then i wouldnt ask for help. Thanks in advance! Yall the best

Answered by RYANTADIPARTHI (3231) [earned 5 cycles]
View Answer
Commentshotnewtop
RYANTADIPARTHI (3231)

Use this code:

total = 1

for i in range(1, 8):
    total = i * total
print(total)

**That should work**
Dominicl645 (428)

that works thx, i noticed that your answer is just a more complicated version of the one im using rn. i really appreciate the help tho yall. @RYANTADIPARTHI

Coder100 (12434)

ok sure, try something like:

output = 1
for i in range(1, 8):
  output *= i
print(i)

for the first problem, and for the second one,

spellList = ["Wendesday", "Tuesday", "February", "November", "Annual", "Calendar", "Solstice"]
for i in range(len(spellList) / 2):
  print(spellList[i])
Dominicl645 (428)

ok i did that and i got this error:
Traceback (most recent call last):
File "main.py", line 12, in <module>
for item in range(len(spellList) / 2):
TypeError: 'float' object cannot be interpreted as an integer @Coder100

Coder100 (12434)

@dominicl645

spellList = ["Wendesday", "Tuesday", "February", "November", "Annual", "Calendar", "Solstice"]
for i in range(int(len(spellList) / 2)):
  print(spellList[i])
MocaCDeveloper (523)

You are attempting to append to a integer variable.

I think you mean to have number1.append(num) on line 8.
Also, on line 13, do:

for item in spellList:
    print(len(item))

Also, do not ping other users unless absolutely needed, especially pinging users just because of there cycles.
Keep it fair and enable everyone to help out, not just one person.

Dominicl645 (428)

i have to use range() for line 13. @MocaCDeveloper

Dominicl645 (428)

i wasn't pinging Coder because of his cycles, i was needing genuine help and he has always been a goto for me. sorry. @MocaCDeveloper

Dominicl645 (428)

because he has given me alot of help. no offence and im not trying to be rude, but do you have a problem with it? because if im correct, users can ping people who have helped them if they have a question or need help themselves. has that changed recently? @MocaCDeveloper

MocaCDeveloper (523)

@dominicl645

No I don't have a problem with it, it is just annoying that that's all anyone does is ping coder100 and ignore everyone else's answers BUT his.

But that was not what I was asking about. I was asking why you need to use the range keyword lol. I don't see why you would need it.

Dominicl645 (428)

my teacher is requiring me to use it. and i dont ignore everyones answer. @MocaCDeveloper

MocaCDeveloper (523)

@dominicl645

No I know you don't, but that does not disregard the fact that users will acknowledge other peoples answers, but as soon as coder100 comments he gets picked as the correct answer.
I don't really care about cycles, but for people who care about cycles probably find it very unfair.

Besides, coder100 is on all the time and I am sure he will come across everyone's most recent question without people needing to ping him lol.

Don't get me wrong, my guy coder100 is pretty outstanding and smart, but it is kinda unfair due to the fact people ping him, disregard everyone else's answers and picks his as the correct one although they might have received like 8 other correct answers xD.

I am not bashing you, or coder100 or anyone who pings him..I understand why people do..but to me it just seems a little bit unfair

Dominicl645 (428)

i understand, im sorry. i wont try to do it again. and i marked someone elses answer correct. @MocaCDeveloper

MocaCDeveloper (523)

@dominicl645

No not my point lol. Ping him if needed. I really don't care. You're actually fair. But other users ignore literally everyone else's answers but his. Again, I have no problem against it and I seriously don't mean to come off being rude in any sort of way.

Sorry if it seemed as if I was coming off rude

Dominicl645 (428)

nah ur fine. you were just letting me know. sorry if i seemed like i was snapping at you. @MocaCDeveloper

OlauPla (154)

Plz don't call coder 100 just for his cycles, many people can also help you!

Dominicl645 (428)

sorry...Coder helped me alot, so he was my goto. [email protected]

Dominicl645 (428)

if your not giving your help then dont comment. its a waste of your and my time. @wqq

OneNose (7)

I REALLY don't understand what you were trying to do, or why you need 13 lines to multiply numbers in a loop. The error is that you declared an integer named total and now you're trying to append items to it as it was a list.

Dominicl645 (428)

any help will be greatly appreciated!

Dominicl645 (428)

dude you get all dem cycles. how u so good at gettin them?
@Coder100