Error in file(file10/31/2023 ![]() ![]() The output will still be even after we close the terminal having our program’s outputs. ![]() One of the simplest ways to save data, is to write to a file. ![]() If you read a number from a file and you want to carry out arithmetic operations, convert it to float using the float() function or integer using the int() function. NOTE: Python treats all text in a text file as a string. ![]() rstrip() #.rstrip() removes the newline character from each line print(yrs_string) # print this string print(len(yrs_string)) # print how long the string is # OUTPUT # 209020702089 # 12 Yrs_string = '' # create a variable yrs_string to hold the digits of years for line in lines: # create a loop that adds each line of digits to yrs_string
0 Comments
Leave a Reply.AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |