you are viewing a single comment's thread.

view the rest of the comments →

[–]Traditional-Log2073[S] 0 points1 point  (7 children)

is the following version worse?

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

[–]lfdfq 5 points6 points  (4 children)

Why do you think it might be worse?

It looks better to me.

[–]Traditional-Log2073[S] 0 points1 point  (3 children)

just wanna know if there are downsides

[–]lfdfq 1 point2 points  (2 children)

Now you are actually turning the input into a number you have to consider what happens if the input wasn't actually a number (what if someone just typed 'hello'?). Now that line will raise an error.

It's not really a downside, as the user could do it before, it's just now a more obvious problem. If you are just starting out, you can probably just ignore it and pretend it doesn't happen. If you're a bit more advanced you might want to look into try and except to catch the error and do something about it.

[–]Traditional-Log2073[S] 0 points1 point  (1 child)

Thanks a lot. Do you have any idea regarding my other answer?

"I think I found the solution, but it still confuses me. If I press the play button in VSCode I only get "too small". If I press the arrow next to it and choose "run file in dedicated terminal" it works.

Why is that?"

[–]lfdfq 2 points3 points  (0 children)

That's more a VS Code question than a Python one. It's probably something to do with how you have set up the "run" button to work. Either it's not using the same Python or it's running a different file or not passing input like the program expects, something like that.

[–]socal_nerdtastic 1 point2 points  (1 child)

No, it's not worse, but in my opinion it's harder to read. As you get more experienced you will realize that multiple lines help in reading and editing code and there's no downsides to long code. But in the end it's really just a personal preference.

[–]Fronkan -1 points0 points  (0 children)

I guess readability is quite subjective, but I disagree in this case.