Ask coding questions

← Back to all posts
Code doesn't run
harisbaig1 (11)

I have been trying to run this code but it does not seemed to run at all. Can some help me what I am missing?

Answered by PattanAhmed (1103) [earned 5 cycles]
View Answer
Commentshotnewtop
PattanAhmed (1103)

@harisbaig1 Hi,
Nah,
It's just fine...

In your code, on line 14 you have this thing:-

number = int(input(""))

Which is taking input with an empty question.

Guess what, that's what you are confusing with that.
That's it

Thanks!
Hope this helps

PattanAhmed (1103)

@harisbaig1 You can make the correct input by asking a question like:-
This is just an example:-

number = int(input("Input a number: "))

Now, it will show Input a number: as an output instead of just empty.

Or else if you don't find it of any use you can remove it.

harisbaig1 (11)

it is still not showing any output =/ @harisbaig1

PattanAhmed (1103)

@harisbaig1 Change all your code like this:-

inpt = int(input("Enter a number that needed to be converted: "))
print("inpt inpt//2 inpt%2")
binary=" "

while(inpt>0):
  print(str(inpt)+" " + str(int(inpt/2)) + " " + str(inpt%2))
  binary = str(inpt%2)+binary
  if inpt/2 == 0:
    break
  inpt = int(inpt/2)

print("Therefore," + str(inpt)+" = 0b" + binary)
harisbaig1 (11)

sure I will paste it on new repl.it thanks a lot. the output is coming as "enter a number" do you know what can I add in input to make the table.? @PattanAhmed

PattanAhmed (1103)

@harisbaig1 Well...
You can think of things.
That usually depends on what you want to make in your program.

harisbaig1 (11)

So if i want my program to output this table what else i can do to add in my input. I reallyappreciate your time

@PattanAhmed

PattanAhmed (1103)

@harisbaig1 Ah...
Sorry to say, Please wait 10-20 seconds after you upload an image.
It didn't fully uploaded yet.
Thanks!

PattanAhmed (1103)

@harisbaig1 Ok,
Well...
Here is the code:-

inpt = int(input("Enter a number: "))
print("inpt inpt//2 inpt%2")
binary = " "

while(inpt>0):
  print('-----------------')
  print(str(inpt)+" " + str(int(inpt/2)) + " " + str(inpt%2))
  binary = str(inpt%2)+binary
  if inpt/2 == 0:
    break
  inpt = int(inpt/2)

print("\nTherefore," + str(inpt)+" = 0b" + binary)

That's it.

harisbaig1 (11)

Reallyappreciated. Do you know why it is still showing the output as 'enter a number' @PattanAhmed

PattanAhmed (1103)

@harisbaig1 Welcome!
Oh...
That's Simple.

In line 1, you have Enter a number: which will ask that question.
You can change that question inside () as you want.

If you want as before, Change your first line like this:-

inpt = int(input("Enter a number that needed to be converted: "))

That's it.

harisbaig1 (11)

so after writing enter a number it should be enter a number 312/2 [email protected]

harisbaig1 (11)

why the table is not showing like one in the [email protected]

PattanAhmed (1103)

@harisbaig1 No...
Enter a number: is a question that needed to be asked to the user.
You can change it as you like.

In this place, you can keep whatever question you want:-

inpt = int(input("This place, you can keep whatever you want."))
harisbaig1 (11)

could you check in your end if it is showing a table as an output. just concern about the table @PattanAhmed

PattanAhmed (1103)

@harisbaig1 If you want to look like the given picture.
Then, Change your code like this:-

inpt = int(input("Enter a number that needed to be converted: "))
print("x    x//2   x%2")
binary = " "

while(inpt>0):
  print('---------------')
  print(str(inpt)+"    " + str(int(inpt/2)) + "    " + str(inpt%2) + '   ')
  binary = str(inpt%2)+binary
  if inpt/2 == 0:
    break
  inpt = int(inpt/2)

print("\nTherefore," + str(inpt)+" = 0b" + binary)

That's it

PattanAhmed (1103)

@harisbaig1 What about the given code?:-

inpt = int(input("Enter a number that needed to be converted: "))
print("x    x//2   x%2")
binary = " "

while(inpt>0):
  print('---------------')
  print(str(inpt)+"    " + str(int(inpt/2)) + "    " + str(inpt%2) + '   ')
  binary = str(inpt%2)+binary
  if inpt/2 == 0:
    break
  inpt = int(inpt/2)

print("\nTherefore," + str(inpt)+" = 0b" + binary)

Is it looking like the table given in the picture?

harisbaig1 (11)

it does but not running as a table in [email protected]

PattanAhmed (1103)

@harisbaig1 It is running as the table...

harisbaig1 (11)

The table in the output. Let me show you a friend of mine his output.

@PattanAhmed

PattanAhmed (1103)

@harisbaig1
If you want your table to like this:-

Then, here is the code:-

inpt = int(input("Enter a number that needed to be converted: "))
print('\n')

print("x    x//2   x%2")
binary = " "

while(inpt>0):
  print('---------------')
  print(str(inpt)+"    " + str(int(inpt/2)) + "    " + str(inpt%2) + '   ')
  binary = str(inpt%2)+binary
  if inpt/2 == 0:
    break
  inpt = int(inpt/2)

print("\nTherefore, " + str(inpt)+" = 0b" + binary)

If you want your table to look like this:-

Then here is the code:-

inpt = int(input("Enter a number: "))
print('\n')

print("x     x//2   x%2")
binary = " "

while(inpt>0):
  print(str(inpt)+"     " + str(int(inpt/2)) + "     " + str(inpt%2) + '    ')
  binary = str(inpt%2)+binary
  if inpt/2 == 0:
    break
  inpt = int(inpt/2)

print("\nTherefore, " + str(inpt)+" = 0b" + binary)

That's it

harisbaig1 (11)

ok great man, thank you alot for your time and support. @PattanAhmed

PattanAhmed (1103)

@harisbaig1 Welcome!
Happy to help you...

Please mark my answer if that helps
Thanks!

harisbaig1 (11)

I have selected your's as best answer, also selected one in all of your's thank you once [email protected]

JosephSanthosh (1192)

It's quite rude how you just copied the code I gave him and edited the input without asking me or telling me. That's really quite rude. @PattanAhmed

JosephSanthosh (1192)

Btw in case you didn't know cycle farming is not allowed nor accepted in repl.it!

What you did here is cycle farming! Have a great day :)

@PattanAhmed

CodeLongAndPros (1365)

@PattanAhmed Woah, woah, don’t ask for upvotes.

JosephSanthosh (1192)

Oh yeah I'm so sorry if you think I'm snitching on you, but the rules are the rules and you even said so yourselves.

LoL!

@PattanAhmed

JosephSanthosh (1192)

No wonder you have 922 cycles when you only have 3 posts which you posted 2 months ago!!! @PattanAhmed

JosephSanthosh (1192)

Lol, just telling a person won't make a difference! @CodeLongAndPros @PattanAhmed

JosephSanthosh (1192)

LoL!

Did you just delete the comment where you cycle farmed? Doing that won't make a difference buddy!!! :(

@PattanAhmed @CodeLongAndPros

PattanAhmed (1103)

@JosephSanthosh Whut?
I didn't copied your code.

PattanAhmed (1103)

@JosephSanthosh Nah...
I don't post that many posts but I answer people's answers dude...

JosephSanthosh (1192)

Umm, sorry to interrupt your periodic argument but you forgot to add cycle farm as well!

LoL!

@PattanAhmed

CodeLongAndPros (1365)

@JosephSanthosh And also, he knows not to do it.

JosephSanthosh (1192)

and FYI the code is literally the same on my explanation as on yours except for the input.

LoL!

@PattanAhmed

JosephSanthosh (1192)

Oh that's good @CodeLongAndPros , so that means he knew he shouldnt do it and still did it!

LoL!

@CodeLongAndPros

CodeLongAndPros (1365)

@JosephSanthosh Please don’t do LoL, lol or LOL is a bit easier on the eyes.

JosephSanthosh (1192)

Haha, sorry, thats @PattanAhmed does in every comment to me. Haha sorry. @CodeLongAndPros

M51 (0)

@harisbaig1 Actually, no. You can do something like this:

number = int(input("Enter the number you wish to convert"))# Question
PattanAhmed (1103)

@JosephSanthosh Lol!

Be careful

I didn't edited that, the mod have edited that.

PattanAhmed (1103)

@JosephSanthosh Wut?
I got all that 922 cycles by answering people's answers.
Do you need proof?
I am not that fan of posting something.
I just answer people's questions.

PattanAhmed (1103)

@CodeLongAndPros ok.
You better said that before.

LoL

PattanAhmed (1103)

@CodeLongAndPros Yes, I know not do it.
But.
It's allowed to ask for marking the answer after the questioner is happy with my answer.

PattanAhmed (1103)

@JosephSanthosh Whut?
Are you serious?

Do you have any proof that I use lol in every comment that I post?

CodeLongAndPros (1365)

@PattanAhmed Yes, that's fine. But you don't say "upovote every comment I ever made kthxbai"

PattanAhmed (1103)

@CodeLongAndPros Ah sorry.
You said now?

I was asking that from before.
r. smh

JosephSanthosh (1192)

Here you go mate, since you asked me for proof.

Haha, you talk big. @PattanAhmed

JosephSanthosh (1192)

@PattanAhmed

You know that you shouldn't be asking people to upvote your comments. You can only ask them to mark your question as correct after you help them and not before or during.

If you know it then why are you still doing it!

JosephSanthosh (1192)

@PattanAhmed Sorry forgot to add this, the most ridiculous proof.

PattanAhmed (1103)

@JosephSanthosh e.
I was not knowing that from before of asking for upvotes.
@CodeLongAndPros send me a warning of please mark as answer
Not of upvotes.

PattanAhmed (1103)

@JosephSanthosh You said on every post.
Although you have found only little.

JosephSanthosh (1192)

What are you saying, can you say it properly? @PattanAhmed

JosephSanthosh (1192)

I said what on every post? What did I find little? Please speak clearly. @PattanAhmed

JosephSanthosh (1192)

There is even a whole article about you and cycle farming here and here and here. You can't deny the fact you cycle farm, do you want proof for this as well? @PattanAhmed

JosephSanthosh (1192)

Forcing or making a big deal out of people choosing your answer as correct is counted as cycle farming, fyi. Did you read the article about you? It has all the information about cycle-farmers. @PattanAhmed

JosephSanthosh (1192)

Oh, Pattan you aren't only getting cycles from answering people's questions, but when I went to comments, I didn't see a single comment which did not have more than 1 upvote. Every comment has 2 or more upvotes and that really sounds fishy, not to ignore the fact you joined repl.it about 2 or 3 months ago and you already have 930 cycles without more than 3 posts. Quite insane! Wish I had the time to look into all the posts you have commented on. @PattanAhmed @CodeLongAndPros

PattanAhmed (1103)

@JosephSanthosh Oh...
So, you want me to prove that I got cycles by my hard work for answering people's questions?

Don't worry,
If you want, I have a whole page of links that I add when people select my answer, I will copy-paste all that here.
Is that proof enough for you, then?

PattanAhmed (1103)

@JosephSanthosh Did I force someone to mark my answer?
Where and where, if so?

JosephSanthosh (1192)

HAHAHA 😂 🤣 ! I'm more than sure that what you meant was that you spent a lot and a lot of hardwork asking people to upvote your comments, and for the first time I agree with you. Sure go ahead and send the pages of links. There should 185 links because you have 900 cycles and each question is worth 5 cycles. Send it. @PattanAhmed

JosephSanthosh (1192)

Dude, are you hallucinating or are you short termed memory? Scroll up and you will find the answer to your own question. @PattanAhmed

JosephSanthosh (1192)

Oh and have you looked at the article, the article about you just proves what I'm talking about. Thank you @Coder100 for making the page about cycle farmers. @PattanAhmed

PattanAhmed (1103)

@JosephSanthosh Ah...
Tell me the place where I forced him to mark my answer.

JosephSanthosh (1192)

Oh don't worry Pattan I'm not jealous of you, I'm way ahead of you so there is no reason for me to be jealous. I'm just suspicous on how you got 900 cycles in less than 3 months when you have not posted more than 3 posts. After all this you still don't know why I'm questioning you, it's cause you were caught cycle farming, and if you are caught once you can be caught more times. The rule is the rule no cycle farming, no about me being jealous of you or ur profile for some reason. BTW you have 17 links here where are the 69 other links, hiding them because you cycle farmed? The mod may have left but I'm sure you've cycle farmed before. Do you even know how to code? Now don't get angry with me because I did what was right by reporting you! THE RULE IS THE RULE NO EXCEPTIONS AND STOP TRYING TO CHANGE THE SUBJECT! @PattanAhmed

HarperframeInc (344)

@PattanAhmed @JosephSanthosh is kinda right. Your trying to squeeze cycles by making your comments short so you have more opportunities to x2 your cycles.

It's kinda unethical. However I am not saying that you can't do this, I just want to say it's unethical and that I was going to make this comment yesterday, but I wasn't able to put it in terms of words.

It doesn't make sense to try to gain extra cycles from people who just want an answer. I understand you want cycles- but for what? You don't earn money from cycles, do you? Will you put it in you resume? No. It's just reputation, like stackoverflow. But unlike stackoverflow, there is no losing cycles from unhelpful answers. So even if you had a lot of cycles, people won't even respect you- you didn't do actual work to deserve it.

I'm not saying this to be rude, but I hope you understand.

JosephSanthosh (1192)

Wow! Well said, like literally. @HarperframeInc

PattanAhmed (1103)

@JosephSanthosh Suspicious, Huh?

Don't worry

I didn't did any cycle farming.

If you want you can check my profile, there are just few upvotes to my comments.
Just scroll down a little bit, you will find yourself that I haven't did any cycle farming by any means.

PattanAhmed (1103)

@JosephSanthosh Ok.
So, what do you mean by cycle farming here?

You mean that I am having two accounts and up-voting my comments?

PattanAhmed (1103)

@HarperframeInc Yes, I understood.
But @JosephSanthosh is like some kind some suspicious on me that I did cycle farming.

I can't make him understand this point.

MrTrex (16)

@PattanAhmed You can do input with an empty queation so thats not the problem ive placed input with an empty queation and i can still run it

JosephSanthosh (1192)

Man! It's about time you go learn some proper english! It's so hard to make you realize you're cycle farmer and that you just cycle farmed. Did you read the article https://repldex.com/entry/Cycle+Wh-ring ? The article describes clearly what a cycle farmer is and what they do which matches you completely. It even mentions you! Not only are you cycle farmer you curse and you inappropriate symbols.

@PattanAhmed

JosephSanthosh (1192)

It's about time you start worrying. If you haven't learnt your lesson, trust me you will!@PattanAhmed

PattanAhmed (1103)

@JosephSanthosh Ah...
You want to delete that post?

So, Done!

PattanAhmed (1103)

@JosephSanthosh That doesn't matches me here.
Because I didn't ask for marking my answer in my first comment.

JosephSanthosh (1192)

No, I did not want you to delete it, you wanted to delete to hide yourself. You didn't ask for your answer to be marked correct in the first comment, you did ask aroung the 8 or 9th comment.

Just accept your mistake shut up!

@PattanAhmed

PattanAhmed (1103)

@JosephSanthosh Yes,
it is allowed.

It's not allowed to post that in the first comment.
We can ask them after the questioner after he/she is convinced with our answer.

That's allowed!

JosephSanthosh (1192)

It is allowed but it is called cycle farming and most of cycle farming are not allowed and people disregard them. @PattanAhmed

JosephSanthosh (1192)

I don't care if your answer got selected or not, you cycle farmed that's what I care about. @PattanAhmed

PattanAhmed (1103)

@JosephSanthosh No.
You are wrong...

That's not cycle farming.
Cycle farming is to post Please mark my answer in the first comment.

JosephSanthosh (1192)

Did you read the article or not? @PattanAhmed

PattanAhmed (1103)

@JosephSanthosh Yeah,
I read all the articles about that!

JosephSanthosh (1192)

Read the article, the article has the definition of cycle farming and you are stated as one of them. @PattanAhmed

JosephSanthosh (1192)

THATS GOOD, SO LONG FOR NOW :)

@PattanAhmed

PattanAhmed (1103)

@JosephSanthosh Ah...
I don't care my name is there or not.
Because it's not updated, I know.

JosephSanthosh (1192)

It was updated two days ago by me and @Coder100! @PattanAhmed

JosephSanthosh (1192)

wat? how did i just get 20 cycles? @Coder100

JosephSanthosh (1192)

@harisbaig1 OMG I'm so sorry! You must be so confused with all these answers but here is the correct code:

inpt=input('Enter the number to convert: ');
x = int(inpt);
print("x x//2 x%2");
binary=" ";

while(x>0):
  print(str(x)+" "+str(int(x/2))+" "+str(x%2));
  binary = str(x%2)+binary;
  if x/2 == 0:
    break;
  x = int(x/2);

print("Therefore,"+inpt+" = 0b"+binary);
number = int(input(""))

It works I just checked it and this is some pretty cool code you made here!

Have a great day and fun coding!

harisbaig1 (11)

ahan! Thanks joseph, it is showing output. @JosephSanthosh

JosephSanthosh (1192)

Sure! If you don't mind marking this as the correct answer? Have a great day! @harisbaig1

harisbaig1 (11)

Sure absolutelythank you for taking out your time. Hey joe do you mind telling me one last time what can i add in input to complete my output as table. The output should look like this

@JosephSanthosh

JosephSanthosh (1192)

the picture isnt attached! Could you send it? @harisbaig1

JosephSanthosh (1192)

It actually did! The only difference is the line in between each number. That can't be done on python unless you have a website or a flask template and that's a whole new part in python. But you actually have the same thing which is on the picture, it just looks a little different, all the answers are the same. @harisbaig1

JosephSanthosh (1192)

Ok so I think i know what the problem is! Replace line 1 with this code:

inpt=input('Enter the number to convert: ');

Hope it worked!

JosephSanthosh (1192)

Nice to meet you!
There isn't actually any error, the code is working perfectly. The issue is that on line 14 the input you made has no text/words in it:

number = int(input(""))

So when you put some words in the input the words will be printed! H
Hope it all works out :)

I hope you find this helpful and have a wonderful day!

JosephSanthosh (1192)

Sure No Problem! Have Fun Coding! :) @harisbaig1

harisbaig1 (11)

Hey sorry joseph,I have a little more confusion, if you could see i have added input in line 14 but the output is still incomplete. I need a table to printout. I can attach picture to make it more clear. If you could figure out where iam wrong.


@harisbaig1

JosephSanthosh (1192)

Hmmm, could you invite me to the repl? @harisbaig1

JosephSanthosh (1192)

Hmm, I'm so sorry I'm not sure about this, you should ask
@Coder100 for the help. Once again I'm sorry. @harisbaig1

Spacecraft (120)

@harisbaig1, It's already working. You just need a few adjustments-

inpt=input('Enter the number to convert: ');
x = int(inpt);
print("x x//2 x%2");
binary=" ";

while(x>0):
  print(str(x)+" "+str(int(x/2))+" "+str(x%2));
  binary = str(x%2)+binary;
  if x/2 == 0:
    break;
  x = int(x/2);

print("Therefore,"+inpt+" = 0b"+binary);
Spacecraft (120)

Since the code in the repl is quite different than what was originally posted (see the original pic), he was getting confused on the direction. He added your comment into line 14, which is now at the end of the code, which defeated the point. I removed that line and added a string to the input callout and it seems to be working fine.

JosephSanthosh (1192)

Oh i get what you mean, my bad. @Spacecraft

Spacecraft (120)

@harisbaig1 why did you swap out the original code for a completely new set?

harisbaig1 (11)

to find out which one could be more relevant with the requirement @Spacecraft

dominicl645 (30)

it does run. or do you want it to do something else, like more detail?

JosephDavies3 (0)

this is absolute pogchamp

m6xie (0)

men in cages 2020

Leroy01010 (373)

i heard that you're a mod can i chat with you @m6xie

Spacecraft (120)

@harisbaig1, your code seems to be running. Because you don't print any statements when asking for your input, the program does nothing until you provide the input. if you add a statement to your input line like this: number = int(input("Enter the number to convert: ")) you will see that it's waiting for user input. It looks like you've got an error associated with line 19. Did you mean to use .reverse() instead of .reserve()? Not sure what you're trying to do.

harisbaig1 (11)

@Spacecraft
hey thank you for figuring out. Yes it is .reverse()
secondly, I am a newbie and working on my first ever project. It is a binary table to made.

MocaCDeveloper (324)

on line 14:

number = int(input(""))

The "" indicates a empty string. Thus is why it looks why your project isn't running. Try putting some text in it!

Coder100 (8676)

hi ready to do the election site? @MocaCDeveloper

MocaCDeveloper (324)

@Coder100 Yep!! I got some of the basics down.

Got a "homepage" going, and I made it to where users can give specific URL'S to go to certain spots of the website.
I also put in an error page that the user gets redirected to if the URL is not valid.

Ping me so I know to go to the repl!!!

harisbaig1 (11)

got it thank you so much ,@MocaCDeveloper

MocaCDeveloper (324)

@Coder100 Alright i'll join here in a minute!

Coder100 (8676)

It is running. Try adding some text to your input on line 14:

number = int(input("number: "))

Also by the way, on line 19, do you mean .reverse()?

binary.reverse()

reserve is not a function btw

Coder100 (8676)

no problem :) mark as correct answer? @harisbaig1

JosephSanthosh (1192)

woahhhhhh, cycle farmer!!! @Coder100

Coder100 (8676)

no thats not cycle farming @JosephSanthosh

JosephSanthosh (1192)

Then why is that i everyone screams at me when I do that! There is even an article about me doing that. That's why I stopped. @Coder100

Coder100 (8676)

@JosephSanthosh yeah, there's a fine line:

they have acknowledged my answer

harisbaig1 (11)

Hey how can i mark correct. Sorry posting first here time @Coder100

JosephSanthosh (1192)

How do I know who made the article? @Coder100

JosephSanthosh (1192)

you wrote that whole article about cycle wh-res ? @Coder100

JosephSanthosh (1192)

Can you please remove my name from there? @Coder100

Coder100 (8676)

@JosephSanthosh oh yeah, I'm so sorry about that

harisbaig1 (11)

Hey i added a number in line 14 but still the output is incomplete. If you could help me out, i can attach picture to make it more sense


@Coder100

harisbaig1 (11)

with line 14 i was jsut trying to put the input along this number to see if the output comes up as a [email protected]

harisbaig1 (11)

sorry If I am making it complex. the second set of code below seems easy for me but still not printing the table that I [email protected]

JosephSanthosh (1192)

Hey thanks for removing my name, it's time to move @PattanAhmed to biggest. He just did this:

And literally just deleted the comment when the mod came to him.

@Coder100 @PattanAhmed

harisbaig1 (11)

My apologies to you guys, I think I am partially responsible for this whole act. I wish I could give you all 5 stars on each comments ya'll made and helped me out. I could not be more dumb to ask you guys all these questions. I wish I could enhance my skills like ya'll. Regardless you guys really helped me out.Joe and ahmed I highly appreciated your time and your efforts. Again I am sorry. @PattanAhmed @JosephSanthosh

JosephSanthosh (1192)

No no no, please don't be sorry! It's not your fault, there was just a violation of the rule one @PattanAhmed side. It isn't biased and it is a mistake on Patten's side. You are perfectly fine, thank you very much for your help. @harisbaig1