Save text into a seperate file, as an integer instead of a string. PYTHON



.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








-3















I'm writing some code for a class, and I can't seem to figure out for the life of me how to get this to work. I'm using mod to find the remainder of a large range of numbers, and taking those numbers that only have the remainder to do the same thing repeatedly. For example:
I have 100 apples, and I want a rem of 1
6 % 6 = 0 so that doesn't fit, but
7 % 6 = 1 so it fits. I do that for every # from 1-100, and take that list and do the same thing with a different remainder. I've been trying to find a decent method of storing all of the numbers that fit the criteria, because the program will search 10s - 100s of thousands of numbers. I settled on taking the first list of #s that fit the mod1, and creating an output file to store them all.
Now all I need to do is reference the output file for the next revision of a different mod, but the output file is stored as a string (says "write() arg must be str, not int") but when I open it back up I can't figure out how to convert it back to all ints so I can use mod again to find a different rem. Heres some code:



enter image description here



With the mod = apple % 8 and if statement commented out, it prints out the whole list that was created in the first part. (I also commented out the line under outputFile on the second part that didn't work)I can't seem to edit that list. ANY help would be appreciated, or perhaps a different method of storing these numbers would be appreciated as well. Thanks! :)










share|improve this question






















  • Images of code are not welcome; images can't be indexed, copy/pasted, or read out loud or rerendered as braille.

    – tripleee
    Dec 12 '18 at 5:52

















-3















I'm writing some code for a class, and I can't seem to figure out for the life of me how to get this to work. I'm using mod to find the remainder of a large range of numbers, and taking those numbers that only have the remainder to do the same thing repeatedly. For example:
I have 100 apples, and I want a rem of 1
6 % 6 = 0 so that doesn't fit, but
7 % 6 = 1 so it fits. I do that for every # from 1-100, and take that list and do the same thing with a different remainder. I've been trying to find a decent method of storing all of the numbers that fit the criteria, because the program will search 10s - 100s of thousands of numbers. I settled on taking the first list of #s that fit the mod1, and creating an output file to store them all.
Now all I need to do is reference the output file for the next revision of a different mod, but the output file is stored as a string (says "write() arg must be str, not int") but when I open it back up I can't figure out how to convert it back to all ints so I can use mod again to find a different rem. Heres some code:



enter image description here



With the mod = apple % 8 and if statement commented out, it prints out the whole list that was created in the first part. (I also commented out the line under outputFile on the second part that didn't work)I can't seem to edit that list. ANY help would be appreciated, or perhaps a different method of storing these numbers would be appreciated as well. Thanks! :)










share|improve this question






















  • Images of code are not welcome; images can't be indexed, copy/pasted, or read out loud or rerendered as braille.

    – tripleee
    Dec 12 '18 at 5:52













-3












-3








-3


0






I'm writing some code for a class, and I can't seem to figure out for the life of me how to get this to work. I'm using mod to find the remainder of a large range of numbers, and taking those numbers that only have the remainder to do the same thing repeatedly. For example:
I have 100 apples, and I want a rem of 1
6 % 6 = 0 so that doesn't fit, but
7 % 6 = 1 so it fits. I do that for every # from 1-100, and take that list and do the same thing with a different remainder. I've been trying to find a decent method of storing all of the numbers that fit the criteria, because the program will search 10s - 100s of thousands of numbers. I settled on taking the first list of #s that fit the mod1, and creating an output file to store them all.
Now all I need to do is reference the output file for the next revision of a different mod, but the output file is stored as a string (says "write() arg must be str, not int") but when I open it back up I can't figure out how to convert it back to all ints so I can use mod again to find a different rem. Heres some code:



enter image description here



With the mod = apple % 8 and if statement commented out, it prints out the whole list that was created in the first part. (I also commented out the line under outputFile on the second part that didn't work)I can't seem to edit that list. ANY help would be appreciated, or perhaps a different method of storing these numbers would be appreciated as well. Thanks! :)










share|improve this question














I'm writing some code for a class, and I can't seem to figure out for the life of me how to get this to work. I'm using mod to find the remainder of a large range of numbers, and taking those numbers that only have the remainder to do the same thing repeatedly. For example:
I have 100 apples, and I want a rem of 1
6 % 6 = 0 so that doesn't fit, but
7 % 6 = 1 so it fits. I do that for every # from 1-100, and take that list and do the same thing with a different remainder. I've been trying to find a decent method of storing all of the numbers that fit the criteria, because the program will search 10s - 100s of thousands of numbers. I settled on taking the first list of #s that fit the mod1, and creating an output file to store them all.
Now all I need to do is reference the output file for the next revision of a different mod, but the output file is stored as a string (says "write() arg must be str, not int") but when I open it back up I can't figure out how to convert it back to all ints so I can use mod again to find a different rem. Heres some code:



enter image description here



With the mod = apple % 8 and if statement commented out, it prints out the whole list that was created in the first part. (I also commented out the line under outputFile on the second part that didn't work)I can't seem to edit that list. ANY help would be appreciated, or perhaps a different method of storing these numbers would be appreciated as well. Thanks! :)







python






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 14 '18 at 2:11









Jacob SmithJacob Smith

615




615












  • Images of code are not welcome; images can't be indexed, copy/pasted, or read out loud or rerendered as braille.

    – tripleee
    Dec 12 '18 at 5:52

















  • Images of code are not welcome; images can't be indexed, copy/pasted, or read out loud or rerendered as braille.

    – tripleee
    Dec 12 '18 at 5:52
















Images of code are not welcome; images can't be indexed, copy/pasted, or read out loud or rerendered as braille.

– tripleee
Dec 12 '18 at 5:52





Images of code are not welcome; images can't be indexed, copy/pasted, or read out loud or rerendered as braille.

– tripleee
Dec 12 '18 at 5:52












1 Answer
1






active

oldest

votes


















0














Check this post




I can't figure out how to convert it back to all ints so I can use mod again to find a different rem




What I understood is that you want to convert the strings read from Output.txt to integers. So to do that you can use int() to convert str to int. To check the type, use type().



#print("type(apple) is ", type(apple))
#print("type(int(apple)) is ", type(int(apple)))
for apple in outputFile:
mod = int(apple) % 8


Source



I hope this helps!






share|improve this answer

























    Your Answer






    StackExchange.ifUsing("editor", function ()
    StackExchange.using("externalEditor", function ()
    StackExchange.using("snippets", function ()
    StackExchange.snippets.init();
    );
    );
    , "code-snippets");

    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "1"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53292210%2fsave-text-into-a-seperate-file-as-an-integer-instead-of-a-string-python%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    Check this post




    I can't figure out how to convert it back to all ints so I can use mod again to find a different rem




    What I understood is that you want to convert the strings read from Output.txt to integers. So to do that you can use int() to convert str to int. To check the type, use type().



    #print("type(apple) is ", type(apple))
    #print("type(int(apple)) is ", type(int(apple)))
    for apple in outputFile:
    mod = int(apple) % 8


    Source



    I hope this helps!






    share|improve this answer





























      0














      Check this post




      I can't figure out how to convert it back to all ints so I can use mod again to find a different rem




      What I understood is that you want to convert the strings read from Output.txt to integers. So to do that you can use int() to convert str to int. To check the type, use type().



      #print("type(apple) is ", type(apple))
      #print("type(int(apple)) is ", type(int(apple)))
      for apple in outputFile:
      mod = int(apple) % 8


      Source



      I hope this helps!






      share|improve this answer



























        0












        0








        0







        Check this post




        I can't figure out how to convert it back to all ints so I can use mod again to find a different rem




        What I understood is that you want to convert the strings read from Output.txt to integers. So to do that you can use int() to convert str to int. To check the type, use type().



        #print("type(apple) is ", type(apple))
        #print("type(int(apple)) is ", type(int(apple)))
        for apple in outputFile:
        mod = int(apple) % 8


        Source



        I hope this helps!






        share|improve this answer















        Check this post




        I can't figure out how to convert it back to all ints so I can use mod again to find a different rem




        What I understood is that you want to convert the strings read from Output.txt to integers. So to do that you can use int() to convert str to int. To check the type, use type().



        #print("type(apple) is ", type(apple))
        #print("type(int(apple)) is ", type(int(apple)))
        for apple in outputFile:
        mod = int(apple) % 8


        Source



        I hope this helps!







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Nov 14 '18 at 3:14

























        answered Nov 14 '18 at 3:08









        FhdFhd

        13




        13





























            draft saved

            draft discarded
















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53292210%2fsave-text-into-a-seperate-file-as-an-integer-instead-of-a-string-python%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            𛂒𛀶,𛀽𛀑𛂀𛃧𛂓𛀙𛃆𛃑𛃷𛂟𛁡𛀢𛀟𛁤𛂽𛁕𛁪𛂟𛂯,𛁞𛂧𛀴𛁄𛁠𛁼𛂿𛀤 𛂘,𛁺𛂾𛃭𛃭𛃵𛀺,𛂣𛃍𛂖𛃶 𛀸𛃀𛂖𛁶𛁏𛁚 𛂢𛂞 𛁰𛂆𛀔,𛁸𛀽𛁓𛃋𛂇𛃧𛀧𛃣𛂐𛃇,𛂂𛃻𛃲𛁬𛃞𛀧𛃃𛀅 𛂭𛁠𛁡𛃇𛀷𛃓𛁥,𛁙𛁘𛁞𛃸𛁸𛃣𛁜,𛂛,𛃿,𛁯𛂘𛂌𛃛𛁱𛃌𛂈𛂇 𛁊𛃲,𛀕𛃴𛀜 𛀶𛂆𛀶𛃟𛂉𛀣,𛂐𛁞𛁾 𛁷𛂑𛁳𛂯𛀬𛃅,𛃶𛁼

            Crossroads (UK TV series)

            ữḛḳṊẴ ẋ,Ẩṙ,ỹḛẪẠứụỿṞṦ,Ṉẍừ,ứ Ị,Ḵ,ṏ ṇỪḎḰṰọửḊ ṾḨḮữẑỶṑỗḮṣṉẃ Ữẩụ,ṓ,ḹẕḪḫỞṿḭ ỒṱṨẁṋṜ ḅẈ ṉ ứṀḱṑỒḵ,ḏ,ḊḖỹẊ Ẻḷổ,ṥ ẔḲẪụḣể Ṱ ḭỏựẶ Ồ Ṩ,ẂḿṡḾồ ỗṗṡịṞẤḵṽẃ ṸḒẄẘ,ủẞẵṦṟầṓế