Beginner needs help

Hi

I am can not figure out why one command works in python but not in pycharm.

It looks like that

 

list(range(10,0,-1))

in python i see this

[10, 9, 8, 7, 6, 5, 4, 3, 2, 1]

in pycharm nothing happens.

 

7 comments
Comment actions Permalink

there is another command does the same thing.

 

full name = "Linus Torvalds"

fullname.split(" ")

 

answer in python:

['Linus', 'Torvalds']

 

nothing in pycharm

0
Comment actions Permalink

That's because interactive python console shows the output of each line, but when you run non-interactively, you should use prints

fullname = "Linus Torvalds"
out = fullname.split(" ")
print(out)
0
Comment actions Permalink

Thanks! How do I do the first example?

 

list(range(10,0,-1))

0
Comment actions Permalink
print(list(range(10,0,-1)))
0
Comment actions Permalink

Thank you very much.I think I understand now.

0
Comment actions Permalink

Hi

 

after this command

 

>>> a = 0
>>> while(a < 12):
... a = (a+1)
... print("a, a**2, a**3")
...
a, a**2, a**3
a, a**2, a**3
a, a**2, a**3
a, a**2, a**3
a, a**2, a**3
a, a**2, a**3
a, a**2, a**3
a, a**2, a**3
a, a**2, a**3
a, a**2, a**3
a, a**2, a**3
a, a**2, a**3

 

I got this answer instead of real numbers.Not only in pycharm but in python as well.

Can anyone tell me where is the bug?

 

Thank you

0
Comment actions Permalink

I found it out.It was the quotation mark's fault.Without that it does execute the command properly.

 

0

Please sign in to leave a comment.