Posts: 1,298
Threads: 38
Joined: Sep 2016
If it ain't broke, I just haven't gotten to it yet.
OS: Windows 10, openSuse 42.3, freeBSD 11, Raspian "Stretch"
Python 3.6.5, IDE: PyCharm 2018 Community Edition
Posts: 58
Threads: 10
Joined: Mar 2017
Aug-15-2017, 02:53 PM
(This post was last modified: Aug-15-2017, 03:03 PM by Bass.)
HI,
Yes, it is fairly straighforward.
You could use the len function to calculate the number of characters in the word that has been inputted e.g. apple.
Where x would be 5 in this case.
Or you could use an if statment to output a unique code or value if the entered word was apple.
1 2 |
if inputted_word = = "apple" :
print ( "!" "$%" )
|
or you could replace certain letters in the word apple with other letters.
Let us know which of these you would like help with, or maybe you want other thoughts.
Bass
"The good thing about standards is that you have so many to choose from" Andy S. Tanenbaum
Posts: 1,298
Threads: 38
Joined: Sep 2016
Aug-15-2017, 03:53 PM
(This post was last modified: Aug-15-2017, 03:53 PM by sparkz_alot.)
(Aug-15-2017, 03:44 PM)777CAIN Wrote: Every time they type something different how does it respond different like if i put apple and it says 6 and i put apple123 can it put 12 ect?
You could create a dictionary:
1 |
my_dict = { 'apple' : 6 , 'apple123' : 12 , 'apple_snapple' : 500 }
|
Of course, you would need to know every possible input a user might enter. You really need to make your question more specific as to what you are trying to do.
If it ain't broke, I just haven't gotten to it yet.
OS: Windows 10, openSuse 42.3, freeBSD 11, Raspian "Stretch"
Python 3.6.5, IDE: PyCharm 2018 Community Edition