#Hello noobs! It is I again with another python question

1 messages · Page 1 of 1 (latest)

cosmic root
#

So in this code, I created a definition called countcoins to take four numbers as inputs from quarters, dimes, nickels, and pennies, and return the total of the amount of money input.

I want my function to look like this: (see second image)

but looks like the this: (first image)

Any help is much appreciated!

#

im forced to run the program like this

#

but i want the function to print statements and allow users to make their own input

noble elk
#

@cosmic root could you please show the rest of your code? More specifically the part where you call the countcoins method

#

Also, what IDE/Code editor are you using? Or should I say- what are sousing to run your code

cosmic root
cosmic root
#

and i don’t know how exactly

noble elk
noble elk
cosmic root
#

i have to use certain code

#

i’ve just been running into walls

#

need it to look like this

noble elk
#

yes yes yes I know what you want it to look like

#
print('You have a total of $' + str(countcoins(quarters, dimes, nickels, pennies))

that's the issue

cosmic root
#

ik

#

i have no idea what to do

#

sorry if this is frustrating

#

im just writing whatever atp

#

@noble elk

noble elk
#

don't worry its fine

#

so.... firtly, you have a variable called coins in which you are trying have all your different coin-inputs. However here the issue is, that you are doing it wrong :)

So to have all the inputs assigned to 1 variable, the variable has to either be a list or a dictionary (there is one more but that's not portant for this)... I would scrap the idea of having them all under 1 variable, and leave them all as their own variables:

dimes = "some number"
pennies = "some number"
.
.
.

now to the function itself. You define the function as the following:

def count_coins(quarters, dimes, nickels, pennies):

When you do this, because of what you put in the brackets, the function requires 4 arguments. You can think of arguments as Variables. When you call the function, you need to assign those variables a value in the process. which you do in one of the previous pictures:

count_coins(0.4, 2, -1, 3) # btw I suggest making the numer 0.4 instead of .4

This is correct, you just need to put it in your code:

quarters = int(input("quarts"))
pennies = int(input("pennies"))
.
.
.

print("You have a total of $" + countcoins(quarters, pennies, ...))
#

I have to go briefly... if you have questions, Ill answer them when I get back

cosmic root
#

i ended up getting it to work

#

believe me this help really does go a long way

#

thank youuuuuuuu

noble elk
cosmic root
#

do you have any dedicated sites yku may recommend for comp sci help?

noble elk
#

Not so much for cs but I can give you something for Python if you would like