Jump to content

Need Help With Writing a program

Hafiz75

Please can some help me write a program for the question below. I have tried my very best.

Question:

a. the user is asked how many lines of RLE compressed data they want to enter
b. the program should check that the number entered is greater than 2 and if it isn’t display a suitable error message and get the user to keep re-entering the number until it is valid
c. if the user entered a valid number, they then enter the compressed data one line at a time until they have entered the specified number of lines
d. once all the compressed data has been entered, the program decompresses the data and displays the ASCII art image

 

Code i have:

Split=(list(input("Enter string: ")))
            Split.append("")
            a = 0
            for i in range(len(Split)):
                try:
                    if (Split in Split) >0:
                        a = a + 1
                    if Split != Split[i+1]:
                        print(Split,a)
                        a = 0
                        
                except IndexError:
                    print()

 

CPU: Ryzen 5 2600X | Motherboard: MSI B450M Mortar (Black) RAM: Corsair Vengeance LPX 16GB (2x 8GB) 3000MHz DDR4 | GPU: MSI Radeon RX 580 ARMOR 8GB | Storage: Samsung 860 QVO 1TB and Samsung 970 EVO 250GB | PSU: Corsair CX650M 650W Case: Cooler Master MasterBox Q300L | Monitor: ASUS VZ279HE | Mouse: Logitech M171 Wireless | Keyboard: Cherry DC 2000 | Mousepad: None | Speakers: Logitech Z333

Link to comment
Share on other sites

Link to post
Share on other sites

You have to use code tags when posting code, click the <> button in the editor and paste your code into the box and insert it into post.

Link to comment
Share on other sites

Link to post
Share on other sites

10 minutes ago, Mira Yurizaki said:

So what's the problem here? And do you have any sample inputs with their expected results?

Problem is that the code i have tried isnt doing whta i want it to do. I have tried my best spent 3 days but still cant get what the question wants me to do. i was asking for some help

 

CPU: Ryzen 5 2600X | Motherboard: MSI B450M Mortar (Black) RAM: Corsair Vengeance LPX 16GB (2x 8GB) 3000MHz DDR4 | GPU: MSI Radeon RX 580 ARMOR 8GB | Storage: Samsung 860 QVO 1TB and Samsung 970 EVO 250GB | PSU: Corsair CX650M 650W Case: Cooler Master MasterBox Q300L | Monitor: ASUS VZ279HE | Mouse: Logitech M171 Wireless | Keyboard: Cherry DC 2000 | Mousepad: None | Speakers: Logitech Z333

Link to comment
Share on other sites

Link to post
Share on other sites

1 minute ago, Safeer Hafiz said:

Problem is that the code i have tried isnt doing whta i want it to do. I have tried my best spent 3 days but still cant get what the question wants me to do. i was asking for some help

Which part of the four things you listed does the program not do?

 

Pre-emptively I'm looking at this one:

Quote

once all the compressed data has been entered, the program decompresses the data and displays the ASCII art image

Which makes no sense to me taken as-is. I'm assuming the input is pre-determined for you and that's what you're entering?

Link to comment
Share on other sites

Link to post
Share on other sites

1 minute ago, Mira Yurizaki said:

Which part of the four things you listed does the program not do?

 

Pre-emptively I'm looking at this one:

Which makes no sense to me taken as-is. I'm assuming the input is pre-determined for you and that's what you're entering?

at the moment i think it does nothing

 

CPU: Ryzen 5 2600X | Motherboard: MSI B450M Mortar (Black) RAM: Corsair Vengeance LPX 16GB (2x 8GB) 3000MHz DDR4 | GPU: MSI Radeon RX 580 ARMOR 8GB | Storage: Samsung 860 QVO 1TB and Samsung 970 EVO 250GB | PSU: Corsair CX650M 650W Case: Cooler Master MasterBox Q300L | Monitor: ASUS VZ279HE | Mouse: Logitech M171 Wireless | Keyboard: Cherry DC 2000 | Mousepad: None | Speakers: Logitech Z333

Link to comment
Share on other sites

Link to post
Share on other sites

1 minute ago, Safeer Hafiz said:

at the moment i think it does nothing

Then let's back up. Instead of trying to do everything, let's look at one item and make sure it works before working on the next one.

 

Please note since this looks like a homework assignment, I'm not going to provide you with any code that solves the problem. I may provide code that can be used, but it's up to you to figure out where it goes.

Link to comment
Share on other sites

Link to post
Share on other sites

1 minute ago, Mira Yurizaki said:

Then let's back up. Instead of trying to do everything, let's look at one item and make sure it works before working on the next one.

 

Please note since this looks like a homework assignment, I'm not going to provide you with any code that solves the problem. I may provide code that can be used, but it's up to you to figure out where it goes.

Yes please could you help me with that. Really would appreciate it.

 

CPU: Ryzen 5 2600X | Motherboard: MSI B450M Mortar (Black) RAM: Corsair Vengeance LPX 16GB (2x 8GB) 3000MHz DDR4 | GPU: MSI Radeon RX 580 ARMOR 8GB | Storage: Samsung 860 QVO 1TB and Samsung 970 EVO 250GB | PSU: Corsair CX650M 650W Case: Cooler Master MasterBox Q300L | Monitor: ASUS VZ279HE | Mouse: Logitech M171 Wireless | Keyboard: Cherry DC 2000 | Mousepad: None | Speakers: Logitech Z333

Link to comment
Share on other sites

Link to post
Share on other sites

3 minutes ago, Safeer Hafiz said:

Yes please could you help me with that. Really would appreciate it.

So let's get this one started:

Quote

the user is asked how many lines of RLE compressed data they want to enter

This should help get you started: https://www.python-course.eu/python3_input.php (I'm also assuming this is Python 3 by the look of things)

Link to comment
Share on other sites

Link to post
Share on other sites

13 hours ago, Mira Yurizaki said:

So let's get this one started:

This should help get you started: https://www.python-course.eu/python3_input.php (I'm also assuming this is Python 3 by the look of things)

rleline=int(input(“How many lines of RLE compressed data do you want?))

CPU: Ryzen 5 2600X | Motherboard: MSI B450M Mortar (Black) RAM: Corsair Vengeance LPX 16GB (2x 8GB) 3000MHz DDR4 | GPU: MSI Radeon RX 580 ARMOR 8GB | Storage: Samsung 860 QVO 1TB and Samsung 970 EVO 250GB | PSU: Corsair CX650M 650W Case: Cooler Master MasterBox Q300L | Monitor: ASUS VZ279HE | Mouse: Logitech M171 Wireless | Keyboard: Cherry DC 2000 | Mousepad: None | Speakers: Logitech Z333

Link to comment
Share on other sites

Link to post
Share on other sites

19 hours ago, Mira Yurizaki said:

So let's get this one started:

This should help get you started: https://www.python-course.eu/python3_input.php (I'm also assuming this is Python 3 by the look of things)

would that be right

 

CPU: Ryzen 5 2600X | Motherboard: MSI B450M Mortar (Black) RAM: Corsair Vengeance LPX 16GB (2x 8GB) 3000MHz DDR4 | GPU: MSI Radeon RX 580 ARMOR 8GB | Storage: Samsung 860 QVO 1TB and Samsung 970 EVO 250GB | PSU: Corsair CX650M 650W Case: Cooler Master MasterBox Q300L | Monitor: ASUS VZ279HE | Mouse: Logitech M171 Wireless | Keyboard: Cherry DC 2000 | Mousepad: None | Speakers: Logitech Z333

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×