vendredi 20 mai 2022

python random error, do they have a fix yet

Traceback (most recent call last):
  File "/Users/milena/python/vosenbMyach.py", line 1, in <module>
    import random
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/random.py", line 49, in <module>
    from math import log as _log, exp as _exp, pi as _pi, e as _e, ceil as _ceil
ImportError: cannot import name 'log' from 'math' (/Users/milena/python/math.py)
milena@Stevens-MBP python % 

and the code that generated it

import random

def GetAnswer(answerNumber):
    if answerNumber == 1 :
        return 'Bet on it'
    elif answerNumber == 2 :
        return 'It is certain'
    elif answerNumber == 3 :
        return 'It is decidly so'
    elif answerNumber == 4 :
        return 'Yes!'
    elif answerNumber == 5 :
        return 'Reply hazy, try again'
    elif answerNumber == 6 :
        return 'Ask again later'
    elif answerNumber == 7 :
        return 'I need more information'
    elif answerNumber == 8 :
        return 'Concentarate!  Try Again!'
    elif answerNumber == 9 :
        return 'My reply is No!'
    elif answerNumber == 10 :
        return 'Outlook is not so goog'
    elif answerNumber == 11 :
        return 'Very Doubtful'
    elif answerNumber == 12 :
        return 'Pray'

print(GetAnswer(random.randint(1,12)))

Do I have to reinstall, did I do a screw up?




Aucun commentaire:

Enregistrer un commentaire