Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Trouble with return
#1
I am super to new to this. I'm working on an assignment that is a calculator that uses random method, defines a function, and uses return.

This is not the full code. I've been boiling it down to its smallest parts trying to figure out what I'm doing wrong. This is the part I'm working on right now.

If I replace return with print, everything works fine, including the full code. But using return is part of the assignment.

What am I doing wrong?

import random

x = random.random()*10
y = random.random()*10
rx = format(x, '.2f')
ry = format(y, '.2f')

def numbers(x,y):

    z = rx + ry
    return z

numbers(x,y)
This looks exactly like half of the examples I've seen online but theirs work fine and I still can't get anything to return a value

Thank you for helping!
Reply


Messages In This Thread
Trouble with return - by Rudy - Mar-02-2019, 09:43 PM
RE: Trouble with return - by purpleicetwice - Mar-02-2019, 10:13 PM
RE: Trouble with return - by Larz60+ - Mar-03-2019, 01:52 AM
RE: Trouble with return - by Rudy - Mar-03-2019, 06:58 PM
RE: Trouble with return - by Rudy - Mar-03-2019, 07:58 PM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020