473,395 Members | 1,584 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

First time coding multiplication in python but always an error comes

I'm a new at python but have a little bit of exp so I typed
a code:-
x=input('Enter the number')
y=input('Enter the number')
print('The product of x and y is');x*y=
END

But it always saysTraceback (most recent call last):
File "C:/Users/lapchief/Documents/Python/Python 1st program.py", line 3, in <module>
print('The product of x and y is');x*y
TypeError: can't multiply sequence by non-int of type 'str'
so plz tell is my code correct and if no then plz tell me what correction I need to do here.
Aug 17 '20 #1
3 5631
dev7060
636 Expert 512MB
The input entered is returned as a string.
Aug 17 '20 #2
You need to convert the inputs to int.Like this
Expand|Select|Wrap|Line Numbers
  1. x=int(input('Enter the number'))
Here is python tutorial for beginners to know more
Aug 31 '20 #3
Ishan Shah
47 32bit
You should take the integer input or convert it into an integer then perform the multiplication of integers.

Expand|Select|Wrap|Line Numbers
  1. mul=int(a)*int(b)
or

Expand|Select|Wrap|Line Numbers
  1. a=int(input("Enter the value of a : "))
  2. b=int(input("Enter the value of b : "))
  3. mul=a*b
Oct 27 '20 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Dennis | last post by:
The setup: Windows XP Pro Python 2.3 GTK+ 2.2.1.2 and pyGTK 1.99.17 for Python 2.3 from http://www.pcpm.ucl.ac.be/~gustin/win32_ports/ I've downloaded and installed per the instructions the...
0
by: Rene | last post by:
I'm trying to learn how to use python for cgi scripts... I created a form that submits some info that I put in a cookie. Then the script calls itself and reads the cookie, and displays a...
2
by: Brad Quinn | last post by:
It appears that IIS hangs the first time two requests are made for same page in quick succession. Although it may very well be something else I'm doing wrong. I have a page (ViewDocument.aspx)...
2
by: Frank | last post by:
I would like to close the cache, so I put the following statement on the head of A.aspx, <%@ OutputCache Duration="1" Location="None" VaryByParam="None"%> However, when I view that A.aspx, and...
16
by: TB | last post by:
Hi all: If you think that the following comments are absolute amateurish, then please bear with me, or simply skip this thread. A couple of months back I made the decision to initiate a...
3
by: srini | last post by:
I have a console application in C#, which calls a .net webservice. The .net webservice calls a stored procedure to retrieve the data. The sp runs for around 3 minutes and get the results. The first...
1
by: Me | last post by:
Hello, The code below runs well on IE 6 and 7. On Firefox it loads the first time but throws the following error on reloads. Error: top is not defined Source File: top.myIFrameBody();...
1
by: Moschops | last post by:
Hello chaps. I decided to have a go at using the Win API. Long time C++ coder, first time coding the Win API. I banged out some lines. #include <windows.h> int main (void)
1
by: fastestindian | last post by:
Hi, I am working on Winodws CE application. While degugging my application runs well. But when i create the build and install it and run it first time it gives me error as Error...
1
by: dougancil | last post by:
I'm creating a datatable for the first time and I'm having some difficulties. I have the following code: Protected Function Dataparse(ByVal Save As String) As String Dim DataSet ds =...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.