Python Forum
changing value and rerunning the code
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
changing value and rerunning the code
#1
i need this for something else i am working on, so i added it into a more simple code,
what i am trying to do is tell the code that if self.w(the third number) is greater than 20, self.z(the second number) will equal 0(in case the user wants that).
now i want the code to run again with the value the user previously put in, and with self.z = o.
class First():
    def number_input(self):
        self.x = int(input("whats your first number?\n"))
        print('your first number is', self.x)

class Second():
    def result(self):
           self.z = self.x + 2
           print('your second number is', self.z)

class Third():
    def last_result(self):
        self.w = self.z + self.x
        print('your third number is',self.w)

class if_over(First, Second, Third):
    def over(self):
        if self.w > 20:
            yes_no = (input("do you want your second number to equal 0?\n"))
            if yes_no == 'yes':
                self.z = 0





obj = if_over()
obj.number_input()
obj.result()
obj.last_result()
obj.over()
Reply


Messages In This Thread
changing value and rerunning the code - by Arifattal - Jan-18-2018, 03:03 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Code changing rder of headers Led_Zeppelin 0 921 Jul-13-2022, 05:38 PM
Last Post: Led_Zeppelin
  Changing a string value to a numerical value using python code and a lamda function Led_Zeppelin 6 1,653 Jul-05-2022, 11:29 PM
Last Post: deanhystad
  changing code to work on a batch of images within a folder Afrodizzyjack 2 2,086 May-12-2020, 08:56 PM
Last Post: Afrodizzyjack

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020