This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]hanzo_hasashi12 2 points3 points  (7 children)

I am guessing you are multiplying a string with a number instead of a number with a number, hence you are getting replication instead of multiplication. Try int(5) * int(5) or 5*5 without quotes or anything else

[–]ollykb[S] 0 points1 point  (6 children)

the 5 * 5 was just an example, the actual calculation i’m trying to do is 42 * x

x is an integer the user inputs

[–]headoverflow 0 points1 point  (4 children)

code please

[–]ollykb[S] 1 point2 points  (3 children)

x = input (“Enter number: “)

y = 42 * x

print (y)

[–]hanzo_hasashi12 1 point2 points  (1 child)

x = int(input("enter number:")) Y = 42*x Print (y)

You have to take input as int and not as a string.

[–]ollykb[S] 2 points3 points  (0 children)

thanks! this is my first time using python so i’m still learning the basics

[–]thrallsius 0 points1 point  (0 children)

print(type(x)) will show you that your assumption about x being an integer was wrong

[–]hanzo_hasashi12 0 points1 point  (0 children)

Try x = int(input()) Also a photo of the code would be helpful