Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 11 months ago.
Improve this question
I am attempting to print the code, but only the first line shows up in the module when ran.
I tried moving lines around entirely but couldn't figure it out. The code is below
num1=input("10")
num2=input("50")
try:
print(int(num1)+int(num2))
except:
print("one of those is not a number")
It will only show 10 on the module.
You seem to be confused on how input() works. The string you provide is printed and what you type into the terminal after it is returned to the variable. If you have no way to type to the program, then input() is not what you're looking for. For more help, the docs for input() can be found here: https://docs.python.org/3/library/functions.html#input
I don't understand what kind of problem are you having here, so I will suggest a few solution to the potential problems you are trying to fix.
The other lines are not printed : looks like that you are a little bit confused about the input() method. See this to learn about : https://docs.python.org/3/library/functions.html#input
The program does not run : the program is unindented and it's mandatory to indent the code in Python, so try to give a tab in the try "body" and in the except "body".
Related
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed last month.
Improve this question
I'm starting to leart some prefect + python and I'm facing a strange error at the very beginning with a very easy script:
I have already tried it in two diferents PC.
It looks like you've installed Prefect 2, but are following instructions for Prefect 1.
I recommend starting with the first steps tutorial in the Prefect docs: https://docs.prefect.io/tutorials/first-steps/
the way with statements work is that the variable you're defining only exists within the indented code block underneath the with statement itself. The end of your code should be:
with Flow("prueba 1") as flow:
carga()
flow.run()
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 7 months ago.
Improve this question
Please see the attached picture of what I am trying to achieve.
I just want the output as showing and not change the list completely. I tried loop was able extract only the first pair of value however no luck after that.
Hope I was able to explain.
So you have a list of dictionaries and only want to print subdomain is that correct? Then it's simple:
for d in dict_list: # Let's say "dict_list" is the list you're working on
print(f"{d['subdomain']}:{d['ports']}")
As others have pointed out do not put pictures it really makes things harder for those who want to help you. Even my answer is just a guess at what you tried to explain and I might get it all wrong.
Edited: Alright I missed the column, in fact you wanted subdomain:ports . I fixed it if you don't mind the hacky format using f-string.
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 2 years ago.
Improve this question
I tried a basic while-loop in Python 3.8 but I always get a syntax error. Anybody know why?
I tried Notepad++ but when I write the loop, Python doesn't run
i = 1
while i <= 5:
print(i)
i += 1
This works in PyCharm, looking at the image it seems that you wrote the if statement
and the print() on the same line. Which also gave me an error.
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 4 years ago.
Improve this question
I'm creating a program for a school assignment that uses python to give basic info on elements on the periodic table. I'm using if/elif/else and print in order to do this. After I got all the if/elif/else statements down I went to test it, and when I type anything in it goes to the else condition, even if I type in something that should go to an elif statement. Code is too long to paste here so I put it in a document here Python version is 3.6.4
I wonder how you are able to run this program, seems to be some harry potter stuff. For me its typo in this line "ele" == input("") and gives Syntax error . So just fix this with ele = input() and replace "ele" with ele in all if/elif checks i.e if ele == "H":it will work as intended.
Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
I try to write some code on Python2.7, which will able to implement a bignum arithmetic, using linear lists. I know, this is useless in Python, but it's my homework in collage. I write some working pieces of code, but problem is in dividing. I'm sure that function works, but when I run code to test it, I just get wrong answer (in some cases). But if I execute code step-by-step, it works correctly.
I'm using linux, but I tested my code on my friend's windows computer, and I got the same problem. I wrote code in Eclipse with PyDev, if it is matter.
My code on Ideone: Code
If lines in console output are the same - output is correct. On Ideone output is incorrect too. But if you put a breakpoint on line 383 and then go in the _simple_div method, answer will be correct
I hope you help me to find a reason of this.
P.S. Sorry for ugly code.
If I run your code, I get
~/coding:$ python divbug2.py
1-1
10
That -1 doesn't look right. Is there a -1 being inserted somewhere in the division? First thing to try is to search for -1 in that function, which gives
i-=1
res._addFirst(i)
if i==-1: i=0
.. and that looks strange, because if i == -1, then you've just added it to res. Maybe we should check first, i.e.
i-=1
if i==-1: i=0
res._addFirst(i)
Swapping those two lines produces
~/coding:$ python divbug2.py
10
10
And then -- after writing a real .copy() method, because copy.deepcopy was really slow and even using PyPy I got bored waiting for things to finish:
>>>> all(int(str(LongNum(x)._simple_div(LongNum(y)))) == x/y for x in range(2000) for y in range(1, 2000))
True
I'm not sure why this was working for you when you did it step-by-step, but I'm a little surprised it worked at all.