Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Indentation
#1
I avoid opening a new thread for indentation problem but I just don't get what is wrong here.

import random
random.seed()

def rollDie():
    return random.choice([1, 2, 3, 4, 5, 6])

def runSim(goal, numTrials):
	total = 0
	for i in range(numTrials):
		result = ''
		for j in range(len(goal)):
			result += str(rollDie())
		if result == goal:
			total += 1
    print('Actual probability =', round(1/(6**len(goal)), 8))
    estProbability = round(total/numTrials, 8)
    print('Estimated Probability =', round(estProbability, 8)) 

runSim('11111', 1000)
Error:
IndentationError: unindent does not match any outer indentation level
is for line 15
print('Actual probability =', round(1/(6**len(goal)), 8))
Reply


Messages In This Thread
Indentation - by Truman - Apr-19-2019, 12:01 AM
RE: Indentation - by ichabod801 - Apr-19-2019, 12:27 AM
RE: Indentation - by Truman - Apr-19-2019, 12:32 AM
RE: Indentation - by kus - Apr-19-2019, 03:33 AM
RE: Indentation - by Truman - Apr-20-2019, 12:04 AM
RE: Indentation - by micseydel - Apr-20-2019, 01:26 AM
RE: Indentation - by Truman - Apr-20-2019, 01:20 PM
RE: Indentation - by Skaperen - Apr-20-2019, 02:08 AM
RE: Indentation - by Skaperen - Apr-21-2019, 01:11 AM
RE: Indentation - by Truman - Apr-21-2019, 02:57 PM
RE: Indentation - by Skaperen - Apr-22-2019, 08:10 PM
RE: Indentation - by Gribouillis - Apr-22-2019, 08:17 PM
RE: Indentation - by Truman - Apr-22-2019, 09:26 PM
RE: Indentation - by Gribouillis - Apr-22-2019, 09:40 PM
RE: Indentation - by Truman - Apr-22-2019, 09:55 PM
RE: Indentation - by Skaperen - Apr-22-2019, 11:54 PM
RE: Indentation - by ehssandannouf - Aug-28-2020, 09:24 AM

Forum Jump:

User Panel Messages

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