[Solved] While Loop and if statement

This should do: import random num = random.randint(7, 14) print num message = “” prevnum = -1 for n in range(num): newnum = random.randint(100, 103) while newnum == prevnum: newnum = random.randint(100, 103) prevnum = newnum message += chr(newnum) You have made numerous mistakes in your code, you should review them. solved While Loop and … Read more

[Solved] Couple of questions about python [closed]

Python is free software, and it’s open source. Anyone can use it in a commercial or public project. Python is not a proprietary language, for the same reasons. Source: https://docs.python.org/3/license.html 13 solved Couple of questions about python [closed]

[Solved] Return Max and min not working right [closed]

Assuming that you want to get the values after the comma, you can do something like this: with open(‘ops.log’, ‘r’) as log_fh: data = [int(line.split(‘,’)[1]) for line in log_fh.readlines()] print max(data), min(data) solved Return Max and min not working right [closed]

[Solved] the continue in for else in python

The latest continue takes effect on the outer for loop, as demonstrated by the following example: >>> for x in [1, 2, 3]: … for y in [4, 5, 6]: … print(‘x =’, x, ‘y =’, y) … else: … continue … print(‘here’) … x = 1 y = 4 x = 1 y = … Read more

[Solved] Python & Strings/Loops help please [closed]

1- Using while loop i = len(full_name.split()) – 1 while(i >= 0): print full_name.split()[i] i = i-1 2- Slicing x = full_name.index(” “) new_string = full_name[x+1:] + ” ” + full_name[0:x] print new_string 3- Counting lower and upper lower = 0 upper = 0 for letter in full_name: if letter.islower(): lower = lower + 1 … Read more

[Solved] Making an RPG in Python

I fixed both your functions. You had your raw_inputs at the wrong place: def yes_or_no(purchase_q): if purchase_q == “yes”: while True: things = raw_input(“Great. What is your hearts desire(type no more to exit shop): “) if things != “no more”: buying_something(things) else: print “Good luck on your journey then” break def buying_something(item): if item in … Read more

[Solved] Hi. I am learning Python and I get stuck with factorial calculation from a number. the codes that I write only return the result once [closed]

Hi. I am learning Python and I get stuck with factorial calculation from a number. the codes that I write only return the result once [closed] solved Hi. I am learning Python and I get stuck with factorial calculation from a number. the codes that I write only return the result once [closed]