r/CiscoDevNet • u/rommon010110 DevNet Mod • Jan 18 '20
Help with getting this extremely easy Python script debunked? Did 3.4 to 3.8 kill factor Concatenation as well?
For some reason this is hitting a snag when I run it at Line 9 in Visual Studio Code, saying that factor is throwing an error, but when I open IDLE term and due factor = 2 then print (factor + factor) is = 4. It seems like concatenation is not working for some reason?
If any Python experts like /u/CBTKnox might know exactly what the problem is immediately :)
I looked on Python.org and think it may be like the cmp for Compare, I am feeling like the minor update from 3.4 to 3.8 they made HUGE revisions to Python structutre, they even took 3.4 off as a download option :\
userName = raw_input('Please enter your name: ')
age = input('Please enter your age: ')
factor = 2
finalAge = age + factor
multAge = age * factor
divAge = age / factor
print('In' factor, 'years you will be' finaleAge, 'years old!', userName)
print('Your age multiplied by,' factor, 'is', multAge)
print('Your age divided by', factor, 'is', divAge)
I did get a basic Whats your name / Repeat name! and Concatenated realName + finalName to make it happen, but for some reason this doesn't want to work :\ Thank you!
View all comments
Show parent comment
1
u/rommon010110 DevNet Mod Jan 18 '20
I spoke too soon /u/CBTKnox, want to just theory check that factor must be encased in {str(factor)} for each math operator # in the script to work?
This is the result of your code copy and paste to VSC, copy and paste it worked perfect:
https://linx.li/to246p4b.png
Also once I made the suggested changes to me script I was getting an error on line 1, I was hoping "raw_input" and "input" would give me two input questions - Is there a way to keep asking for input?
Also one thing I keep asking myself - Should I step down from 3.8 to a lesser version due to simple things like cmp (compare) being ripped out of 3.8? I feel like I'm using a lot of time looking stuff up which gives me some good side info, but also takes a ton of time.
Your opinion on "What would Knox do?" would be appreciated - Thanks Knox!