-1

I am working on learning python and I for some reason the output I get is always incorrect. Not sure what I'm doing wrong or how to fix it and any help is greatly appreciated:

##a.    3 variables —
##  The name of a movie
##  The number of tickets to purchase
##  The total cost of tickets purchased
##
##b.        1 Constant —
##  The cost of a single ticket
##2.    Create four print statements that will display the values of the variables and the constant along with labels that describe them
##

#Initialize
movieNm = str("")
numTickets = int(0)
totalTicketPrice = float(0.0)

SINGLE_TICKET = int(10)

#input
name = input("Enter the name of the movie you would like to see:")
numTickets = input("Enter the number of tickets you wish to purchase:")


#process
totalTicketPrice = SINGLE_TICKET * numTickets


#output
print("Feature Film", name)
print("Cost of single ticket", SINGLE_TICKET)
print("Number of Tickets purchased", numTickets)
print("Your Total", SINGLE_TICKET * numTickets)

When you test the code the output is always just so wrong and I'm not sure how to fix it. thanks!

vexxed
  • 1
  • `str("")`, `int(0)` etc are entirely redundant. Just `""`, `0` etc is entirely sufficient to initialize a string and an int respectively. – deceze Sep 05 '21 at 06:17

1 Answers1

1

in this line numTickets = input("Enter the number of tickets you wish to purchase:") when you got user input you got string you should convert this input to int like below:

numTickets = int(input("Enter the number of tickets you wish to purchase:"))

see this example maybe help you (this example happen in your code):

print('2'*10)
# 2222222222
I'mahdi
  • 23,382
  • 5
  • 22
  • 30