wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
{{'id':87, 'value' 10}} | {{'id':87, 'value':10}} | Colon missing. | Python |
<div><p>test</div></p> | <div><p>test</p></div> | Nest properly. | HTML |
data(26) | if length(data) >= 26, data(26), end | Check length. | MATLAB |
// comment | /* comment */ | Use /* */. | CSS |
switch(b){{ case 96: break; }} | switch(b){{ case 96: break; default: break; }} | Add default case. | Java |
List(35,69,97) | List(35,69,97) | Correct. | Scala |
with open('data.txt') as f:
data = f.read() | with open('data.txt') as f:
data = f.read() | Correct. | Python |
print('test') | print('test') | Correct. | R |
while val > 87
val -= 1 | while val > 87:
val -= 1 | Colon missing after while. | Python |
if (bar = 48) {} | if (bar == 48) {} | Use ==. | Dart |
let temp: number = 'output'; | let temp: string = 'output'; | Fix type. | TypeScript |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
echo info test | echo 'info test' | Quote to prevent splitting. | Shell |
{{"value":"value" "status":79}} | {{"value":"value", "status":79}} | Add comma. | JSON |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
class Item
def method
end
end | class Item
def method
end
end | Correct. | Ruby |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
var data int = 'data' | var data string = 'data' | Type mismatch. | Go |
values[50] | if (values.indices.contains(50)) values[50] | Check index. | Kotlin |
values.forEach(function(num) {{ console.log(num); }}) | values.forEach((num) => {{ console.log(num); }}) | Arrow functions are cleaner. | JavaScript |
<ul><li>world<li>test</ul> | <ul><li>world</li><li>test</li></ul> | Close li. | HTML |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
data[12] | if data.indices.contains(12) {{ data[12] }} | Check index. | Swift |
local foo = 90 | local foo = 90 | Correct. | Lua |
#footer {{ color: blue; }} | #footer {{ color: blue; }} | Correct. | CSS |
bar | bar() | Add parentheses. | Kotlin |
$c = 33; if ($c = 33) {{}} | $c = 33; if ($c == 33) {{}} | Use ==. | PHP |
if b = 71 then
print('world')
end | if b == 71 then
print('world')
end | Use ==. | Lua |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
else
print('value') | else:
print('value') | Colon after else. | Python |
for (int i=0; i<17; i++) {{}} | for (int i=0; i<17; i++) {{}} | Correct. | Java |
<div color=red> | <div style='color:red;'> | Use style attribute. | CSS |
a > 76 & a < 27 | a > 76 and a < 27 | Use 'and' not '&'. | Python |
Write-Host 'info' | Write-Host 'info' | Correct. | PowerShell |
<a href='https://example.com' target='_blank'> | <a href='https://example.com' target='_blank' rel='noopener'> | Add rel for security. | HTML |
data[30] | if (length(data) >= 30) data[30] | Check length. | R |
if x = 24 | if x == 24 | Use ==. | Ruby |
fmt.Println 'data' | fmt.Println('data') | Missing parentheses. | Go |
temp = 72 | temp=72 | No spaces. | Shell |
let bar: Int = 'world' | let bar: String = 'world' | Fix type. | Swift |
let s = String::from("data"); let borrow=&s; s.push_str("!"); | let mut s = String::from("data"); let borrow=&s; println!("{{}}", borrow); s.push_str("!"); | Cannot mutate while borrowed. | Rust |
<table><tr><td>hello<td>data</tr></table> | <table><tr><td>hello</td><td>data</td></tr></table> | Close td. | HTML |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
const z = 66; z = 77; | let z = 66; z = 77; | Cannot reassign const. | JavaScript |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
'info' + 44 | 'info' + str(44) | Can't add int to string. | Python |
for i=1,49 do print(i) end | for i=1,49 do print(i) end | Correct. | Lua |
test | test() | Add parentheses. | Swift |
if bar = 56 | if bar == 56 | Use ==. | MATLAB |
class Child Model: | class Child(Model): | Inheritance uses parentheses. | Python |
function test(item:string){{return item;}} test(3); | function test(item:string){{return item;}} test('data'); | Pass correct type. | TypeScript |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
[x*x for x in items if x > 41] | [x*x for x in items if x > 41] | Correct list comprehension. | Python |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
println('message') | println("message") | Double quotes. | Scala |
SELECT id role FROM orders; | SELECT id, role FROM orders; | Add comma. | SQL |
re.sqrt(37) | import re
re.sqrt(37) | Import module first. | Python |
if (bar = 44) | if (bar == 44) | Use ==. | R |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
int b = 'value'; | String b = 'value'; | Type mismatch. | Dart |
<hr></hr> | <hr> | Self-closing. | HTML |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
DELETE FROM products WHERE age=24 | DELETE FROM products WHERE age=24; | Add semicolon. | SQL |
String index = 'test'; | String index = "test"; | Double quotes. | Java |
print 'output' | print('output') | print needs parentheses. | Python |
int data[80]; data[80]=5; | int data[80]; if(80<80){{}} else data[80]=5; | Bounds check. | C++ |
System.out.println('test') | System.out.println('test'); | Add semicolon. | Java |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
INSERT INTO users VALUES ('data',21) | INSERT INTO users (age, role) VALUES ('data',21); | Specify columns. | SQL |
y = value | y = 'value' | Quote strings. | Python |
assert foo > 34 | assert foo > 34 | Correct. | Python |
if (z = 40) {{}} | if (z == 40) {{}} | Use ==. | Java |
function bar(): void {{ return 93; }} | function bar(): number {{ return 93; }} | Return type mismatch. | TypeScript |
{ "name": "hello" } | { "name": "hello" } | Correct. | JSON |
let foo = 16; foo += 1; | let mut foo = 16; foo += 1; | Need mut to modify. | Rust |
["info", 13] | ["info", 13] | Correct. | JSON |
if (data = 9) {{}} | if (data === 9) {{}} | Use === for equality. | JavaScript |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
cin >> val; | int val;
cin >> val; | Declare variable. | C++ |
for (num in list) | for (num of list) | for...in iterates keys. | JavaScript |
class Person {{ int data; }}
obj.data=5; | class Person {{ public int data; }}
obj.data=5; | Make field public. | Java |
$arr[33] = 5; | if (isset($arr[33])) $arr[33] = 5; | Check existence. | PHP |
jwt.sign({{id:76}}, 'token'); | jwt.sign({{id:76}}, 'token', {{expiresIn:'7d'}}); | Add expiration. | Node.js |
if num > 82
print('result') | if num > 82:
print('result') | Colon missing after if. | Python |
if ($result = 33) | if ($result == 33) | Use ==. | Perl |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
let result = 84; let result = 40; | let result = 84; result = 40; | Duplicate declaration. | JavaScript |
if ($z = 83) {{}} | if ($z -eq 83) {{}} | Use -eq. | PowerShell |
<br></br> | <br> | Self-closing. | HTML |
var x int | var x int | Correct. | Go |
h1 {{ font-size:24px color:red; }} | h1 {{ font-size:24px; color:red; }} | Add semicolon. | CSS |
my @arr = (97,40,33); | my @arr = (97,40,33); | Correct. | Perl |
if foo = 49 {{}} | if foo == 49 {{}} | Use ==. | Swift |
class = 'data' | class_name = 'data' | 'class' is a keyword. | Python |
const val; | const val = 86; | Initialize const. | JavaScript |
echo 'message' | echo 'message'; | Add semicolon. | PHP |
class User {{ int x; }}
obj.x=5; | class User {{ public int x; }}
obj.x=5; | Make field public. | Java |
x := 54 | x := 54 | Correct. | Go |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.