--Originally published at Programming Blog
Since there is missing several topics to myself the 4th part will be postponed but DON’T WORRY! it will be done faster than you think
7!
- Validated user input (ensure correct/expected data entry)
Just as the topic says, you gotta make sure that what the input that any person is giving to you is the one that you code into, for example: enter your age, and if you put three it shows you that’s not a number, type a number, that means it requires you to type an integer.
And the way that i did it is with, errors and exceptions, that means using while True, you know what? it’s better to see the explanation of the documentation (link) and my code
I think the documentation is really nice written but if you still have problems with it or don’t understand this guy really know’s how to explain it (starts at1:52) https://www.youtube.com/watch?v=nqGhjLUhyDc
https://docs.python.org/3/tutorial/errors.html#handling-exceptions
8!
- Reading and writing of text files
In Python you have it really simple, first, you don’t need to import any libraries to read text files (yei) but you need to get a file object and the way to do this is with the open function, to read a text file is rather easy and it’s only with a simple file.read() function, also you can decide if you want the whole text or several characters and it would be inside the file.read(x), being x this time
And for writing inside it will be with the function file.write (“text”).
Tip! after you are done calling the text file you gotta close it to free memory with the function call f.close().
my code won’t work since i don’t have a text file to use if for example you change the 2nd line and the 3rd it will print the hole text + this is a test, since you are writting it.
https://www.youtube.com/watch?v=S1EjCcZUw34
https://docs.python.org/3/tutorial/inputoutput.html
you might realized about the numbers of 1! 2! 3! 4! 5! 6! 7! 8! So guess what! it is an easter egg, how many medals does each region has? (Chan-chan-chan!) i already gave you the answer but don’t worry there is another easter egg, good luck finding it, and don’t forget to code always, you rust if you don’t do it.
#TC101 #Pokemon #Pokefun