0
import urllib,re

def getver():
    url='https://github.com/Bendr0id/xmrigCC/releases'
    website = urllib.urlopen(url)
    html = website.read()
    links = re.findall(r'(?<=<a href=")[^"]*\bgcc-win64.zip\b', html)
    link=links[0]
    version=link.split('/')
    ver0=version[5]
    return ver0
getver()

I've tried to run the code but it doesnt output anything,instead when I replace return with print it prints out the correct answer which is 1.5.2 . What am I doing wrong?

  • 3
    Code that doesn't print anything doesn't print anything. That's expected behavior. You're not doing anything wrong. If you want to print something, you have to call `print` on it. – Aran-Fey Mar 29 '18 at 22:23

2 Answers2

0

Change the last line to:

print(getver())
Preston
  • 7,399
  • 8
  • 54
  • 84
0

You have been fooled by the interactive interpeter's friendly habit of printing out the results of any bare expressions you enter.

This does not happen when you run a program, so you need to ensure you output values specifically by using the print statement.

This is specifically mentioned in a rather obscure portion of the Python documentation dealing with the language's grammar.

holdenweb
  • 33,305
  • 7
  • 57
  • 77