# Zero experience python user needs help

**URL:** <https://discuss.python.org/t/zero-experience-python-user-needs-help/41785>\
**Category:** Python Help\
**Created:** [December 23, 2023, 5:45pm UTC](https://discuss.python.org/t/zero-experience-python-user-needs-help/41785 "2023-12-23T17:45:32Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![Helenpythonnewbie](https://avatars.discourse-cdn.com/v4/letter/h/7bcc69/32.png) [@Helenpythonnewbie](https://discuss.python.org/u/Helenpythonnewbie)\
**Post date:** [December 23, 2023, 5:45pm UTC](https://discuss.python.org/t/zero-experience-python-user-needs-help/41785/1 "2023-12-23T17:45:32Z")

</div>

Hi I am learning python but it’s not going well can some one explain something please.

---

<div class="post-metadata">

**Author:** ![d\_n](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/d_n/32/7498_2.png) [@d\_n](https://discuss.python.org/u/d_n)\
**Post date:** [December 23, 2023, 7:28pm UTC](https://discuss.python.org/t/zero-experience-python-user-needs-help/41785/2 "2023-12-23T19:28:54Z")

</div>

“Ask and thou shalt receive”!  
What is the problem you are tackling?  
What have you coded so-far?  
(and assuming you are attempting a course, which course or book are you using?)

---

<div class="post-metadata">

**Author:** ![Helenpythonnewbie](https://avatars.discourse-cdn.com/v4/letter/h/7bcc69/32.png) [@Helenpythonnewbie](https://discuss.python.org/u/Helenpythonnewbie)\
**Post date:** [December 23, 2023, 7:46pm UTC](https://discuss.python.org/t/zero-experience-python-user-needs-help/41785/3 "2023-12-23T19:46:14Z")

</div>

Hi I’m on LinkedIn learning and I have done Hello World lol a bit of ints and floats string Boolean. But I thought I’d have a go at an exercise and no matter how I did it it didn’t work. so this is the challenge, Exercise 1: Calculate the multiplication and sum of two numbers

Given two integer numbers, return their product only if the product is equal to or lower than 1000. Otherwise, return their sum.

**Given** 1:

number1 = 20 number2 = 30

**Expected Output** :

The result is 600

**Given** 2:

number1 = 40 number2 = 30

**Expected Output** :

The result is 70

and this is what I did but no matter what I do it don’t work. I don’t get it,

def multiplication\_or\_sum(num1, num2):  
# calculate product of two number  
product = num1 \* num2  
# check if product is less then 1000  
if product \<= 1000:  
return product  
else:  
# product is greater than 1000 calculate sum  
return num1 + num2

# first condition

result = multiplication\_or\_sum(20, 30)  
print(“The result is”, result)

# Second condition

result = multiplication\_or\_sum(40, 30)  
print(“The result is”, result)

---

<div class="post-metadata">

**Author:** ![Helenpythonnewbie](https://avatars.discourse-cdn.com/v4/letter/h/7bcc69/32.png) [@Helenpythonnewbie](https://discuss.python.org/u/Helenpythonnewbie)\
**Post date:** [December 23, 2023, 7:46pm UTC](https://discuss.python.org/t/zero-experience-python-user-needs-help/41785/4 "2023-12-23T19:46:46Z")

</div>

no clue what it means lol I have only been learning for like an hour

---

<div class="post-metadata">

**Author:** ![Helenpythonnewbie](https://avatars.discourse-cdn.com/v4/letter/h/7bcc69/32.png) [@Helenpythonnewbie](https://discuss.python.org/u/Helenpythonnewbie)\
**Post date:** [December 23, 2023, 7:48pm UTC](https://discuss.python.org/t/zero-experience-python-user-needs-help/41785/5 "2023-12-23T19:48:48Z")

</div>

then I tried

number1 = 20  
number2 = 30  
if number1 \<=1000:  
print (‘number1’ + ‘number2’)

def multiplication\_or\_sum (num1, num2):  
# calculate product of two number  
prouct = num1 \* num2  
# check if product is less than 1000  
if product \<=1000:  
return product  
else:

# product is greater than 1000 calculate sum

return num1 + num2

# first condition:

result = multiplication\_or\_sum (20, 30)  
print (‘the result is’, result)

# second condition

result = multiplication\_or\_sum (40, 30)  
print (‘The result is’, result)

and all I get are syntax errors

---

<div class="post-metadata">

**Author:** ![d\_n](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/d_n/32/7498_2.png) [@d\_n](https://discuss.python.org/u/d_n)\
**Post date:** [December 23, 2023, 7:58pm UTC](https://discuss.python.org/t/zero-experience-python-user-needs-help/41785/6 "2023-12-23T19:58:48Z")

</div>

When working with Python, indentation is important.  
When working with this system, copy-paste the code from your IDE and use the \</\> formatter (ribbon-bar during Reply) to preserve spacing.  
Also, please copy-paste ALL of the “stack trace” - the lines of error message, location within the code, etc.

---

<div class="post-metadata">

**Author:** ![Helenpythonnewbie](https://avatars.discourse-cdn.com/v4/letter/h/7bcc69/32.png) [@Helenpythonnewbie](https://discuss.python.org/u/Helenpythonnewbie)\
**Post date:** [December 23, 2023, 8:04pm UTC](https://discuss.python.org/t/zero-experience-python-user-needs-help/41785/7 "2023-12-23T20:04:59Z")

</div>

sorry for being thick but I don’t know what an IDE is, but here are error messages:  
File “/home/runner/variables/main.py”, line 117  
{set\_a} {set\_b}  
^  
SyntaxError: invalid syntax

I hope that makes sense, it probably doesn’t, like the console shows old stuff I was trying not the sum one I’m trying to workout, the solution on the site I used made zero sense, I have put the link in below.

> **[Python Basic Exercise for Beginners](https://pynative.com/python-basic-exercise-for-beginners/)**
>
> Python essential exercise is to help Python beginners to quickly learn basic skills by solving the questions.When you complete each question, you get more familiar with a control structure, loops, string, and list in Python.

---

<div class="post-metadata">

**Author:** ![Helenpythonnewbie](https://avatars.discourse-cdn.com/v4/letter/h/7bcc69/32.png) [@Helenpythonnewbie](https://discuss.python.org/u/Helenpythonnewbie)\
**Post date:** [December 23, 2023, 8:12pm UTC](https://discuss.python.org/t/zero-experience-python-user-needs-help/41785/8 "2023-12-23T20:12:43Z")

</div>

File “/home/runner/variables/main.py”, line 127  
return num1 + num2  
^^^^^^^^^^^^^^^^^^  
SyntaxError: ‘return’ outside function

---

<div class="post-metadata">

**Author:** ![Helenpythonnewbie](https://avatars.discourse-cdn.com/v4/letter/h/7bcc69/32.png) [@Helenpythonnewbie](https://discuss.python.org/u/Helenpythonnewbie)\
**Post date:** [December 23, 2023, 8:13pm UTC](https://discuss.python.org/t/zero-experience-python-user-needs-help/41785/9 "2023-12-23T20:13:41Z")

</div>

I think ill give up

---

<div class="post-metadata">

**Author:** ![barry-scott](https://avatars.discourse-cdn.com/v4/letter/b/e9c0ed/32.png) [@barry-scott](https://discuss.python.org/u/barry-scott)\
**Post date:** [December 23, 2023, 9:03pm UTC](https://discuss.python.org/t/zero-experience-python-user-needs-help/41785/10 "2023-12-23T21:03:57Z")

</div>

You can format your replies so that they are easy to read by doing this:  
(note the three back ticks “`”)

````auto
```
def mycode():
     print('Hello')
```

````

---

<div class="post-metadata">

**Author:** ![d\_n](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/d_n/32/7498_2.png) [@d\_n](https://discuss.python.org/u/d_n)\
**Post date:** [December 23, 2023, 9:05pm UTC](https://discuss.python.org/t/zero-experience-python-user-needs-help/41785/11 "2023-12-23T21:05:03Z")

</div>

IDE = code editor

The error talking about sets is entirely unconnected with the multiply/add script.

The “return outside function” error sounds like a problem with indentation (as above).

Personal opinions follow:  
I took a quick look at the course quoted (emphasis on the “quick”!) and was confused. Perhaps goes over-board on the idea of “quickly” and makes assumptions - or perhaps you’ve been a little bit too fast for your own good. I am biased towards Internet courses and those university-led in-particular. Have not been impressed by LinkedIn, ie Lynda post-takeover; as a gross generalisation.

Recommend taking a look at Coursera and edX (I use the latter). Most of those will start-off with the basics (again, as-above) and whilst it might seem slow, is more-likely to lead to success. After all, if you can’t get out of the starting-blocks, how could you ever expect to win the race?

If that approach is too formal for your taste, have you noted [The Python Tutorial](https://docs.python.org/3/tutorial/index.html) - part of the Python documentation set?

---

<div class="post-metadata">

**Author:** ![Helenpythonnewbie](https://avatars.discourse-cdn.com/v4/letter/h/7bcc69/32.png) [@Helenpythonnewbie](https://discuss.python.org/u/Helenpythonnewbie)\
**Post date:** [December 23, 2023, 10:01pm UTC](https://discuss.python.org/t/zero-experience-python-user-needs-help/41785/12 "2023-12-23T22:01:34Z")

</div>

Brilliant I’ll check that out. I think u are right. I’ll slow down and read more.

---

<div class="post-metadata">

**Author:** ![Helenpythonnewbie](https://avatars.discourse-cdn.com/v4/letter/h/7bcc69/32.png) [@Helenpythonnewbie](https://discuss.python.org/u/Helenpythonnewbie)\
**Post date:** [December 23, 2023, 10:02pm UTC](https://discuss.python.org/t/zero-experience-python-user-needs-help/41785/13 "2023-12-23T22:02:15Z")

</div>

I’ll have a go thank u.

---

<div class="post-metadata">

**Author:** ![kknechtel](https://avatars.discourse-cdn.com/v4/letter/k/e47c2d/32.png) [@kknechtel](https://discuss.python.org/u/kknechtel)\
**Post date:** [December 24, 2023, 8:23am UTC](https://discuss.python.org/t/zero-experience-python-user-needs-help/41785/14 "2023-12-24T08:23:50Z")

</div>

Please [read the pinned thread](https://discuss.python.org/t/about-the-python-help-category/42) in order to understand how to make the code show up properly on the forum. In order for us to help you with the code, we need to be able to see it the same way it looks in your editor.

Just to make sure: you should use either an ordinary _text editor_ like Notepad (or TextEdit, xed, gvim, whatever else you’re used to depending on your operating system…), or else an _IDE_ (a program specially designed to organize the process of typing out and running the code, that can also give you some suggestions as you type, etc.). Do **not** use a word processor like Word or Wordpad (or LibreOffice etc.).

Also: please don’t tell people “it doesn’t work” - in order to understand a problem properly, we need to make sure we understand a) what you tried (not just the part where you typed the code, but also how you tried to make it run); b) _what happened_ when you did that (what you can see happening), and c) _how that is different_ from what you expected. If you get an error message, you should copy and paste a _complete_ error message, and format it like the code.
