Jump to content

Recommended Posts

Posted
import math
import random
 
print("picle price is changing every day")
piclePrice = random.randint(3,9)
picleamount = input("Enter picle amounth:")
 
print(' price: '+piclePrice)
 
results = (picleamount*piclePrice)
print(results)
#once i put amount i get the price
  • 2 years later...
Posted

To multiply two variables in Python, both variables need to be of numeric types (e.g., integers or floats). In your code, the picleamount variable is being read as a string from the input function. You need to convert it to an integer or float before performing the multiplication.

Here is the corrected version of your script:

import random

print("Pickle price is changing every day")
pickle_price = random.randint(3, 9)
pickle_amount = int(input("Enter pickle amount:"))

print('Price per pickle:', pickle_price)

# Calculate the total price
total_price = pickle_amount * pickle_price
print('Total price:', total_price)

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...