wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
{{"title":"hello" "value":69}} | {{"title":"hello", "value":69}} | Add comma. | JSON |
Write-Host 'data' | Write-Host 'data' | Correct. | PowerShell |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
<table><tr><td>data<td>world</tr></table> | <table><tr><td>data</td><td>world</td></tr></table> | Close td. | HTML |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
<ul><li>test<li>data</ul> | <ul><li>test</li><li>data</li></ul> | Close li. | HTML |
String name = 'result'; | String name = 'result'; | Correct. | Dart |
System.out.println('hello') | System.out.println('hello'); | Add semicolon. | Java |
re.sqrt(7) | import re
re.sqrt(7) | Import module first. | Python |
val val = 'data' | val val = "data" | Double quotes. | Kotlin |
void main() {{ print('test') }} | void main() {{ print('test'); }} | Add semicolon. | Dart |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
val z = 100; z = 33 | var z = 100; z = 33 | Use var for reassignment. | Scala |
const person:Person = {{name:'output'}}; | const person:Person = {{name:'output', age:11}}; | Add missing property. | TypeScript |
{{'title':5, 'value' 41}} | {{'title':5, 'value':41}} | Colon missing. | Python |
// comment | /* comment */ | Use /* */. | CSS |
if ($c = 27) | if ($c == 27) | Use ==. | Perl |
let x = 5; let x = 44; | let x = 5; x = 44; | Duplicate declaration. | JavaScript |
function compute() {{ echo 'value'; }} | function compute() {{ echo 'value'; }} | Correct. | PHP |
int index = 'value'; | String index = 'value'; | Type mismatch. | Dart |
if b = 58 | if b == 58 | Use ==. | Go |
def render(temp):
return temp + 1 | def render(temp):
return temp + 1 | Correct. | Python |
let c = 'world' | let c = "world" | Double quotes. | Swift |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
def render
puts 'result'
end | def render
puts 'result'
end | Correct. | Ruby |
for z in range(21)
print(z) | for z in range(21):
print(z) | Colon after for. | Python |
x := 83 | x := 83 | Correct. | Go |
print 'hello' | print 'hello'; | Add semicolon. | Perl |
WHERE email = '70' | WHERE email = 70 | Don't quote integer. | SQL |
int* user = nullptr; *user=5; | int* user = new int; *user=5; | Allocate memory. | C++ |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
jwt.sign({{id:46}}, 'password'); | jwt.sign({{id:46}}, 'password', {{expiresIn:'30m'}}); | Add expiration. | Node.js |
DELETE FROM users WHERE age=98 | DELETE FROM users WHERE age=98; | Add semicolon. | SQL |
class Child Base: | class Child(Base): | Inheritance uses parentheses. | Python |
let index: Int = 'world' | let index: String = 'world' | Fix type. | Swift |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
if (b = 84) {{}} | if (b == 84) {{}} | Use ==. | Kotlin |
let data: number = 'output'; | let data: string = 'output'; | Fix type. | TypeScript |
48z = 10 | z48 = 10 | Variable cannot start with digit. | Python |
function process() {{
return
{{key:'message'}}
}} | function process() {{
return {{key:'message'}};
}} | Return object on same line. | JavaScript |
val == '59' | val === 59 | Use strict equality. | JavaScript |
id: info
title: world, | id: info
title: world | Remove comma. | YAML |
for (int i=0; i<66; i++) {{}} | for (int i=0; i<66; i++) {{}} | Correct. | Java |
{{"name":"message",}} | {{"name":"message"}} | Remove trailing comma. | JSON |
console.log('info' | console.log('info') | Close parenthesis. | JavaScript |
UPDATE orders SET name='test' WHERE role=42 | UPDATE orders SET name='test' WHERE role=42; | Add semicolon. | SQL |
[16, 47, 74 | [16, 47, 74] | Close bracket. | Ruby |
'value' + 66 | 'value' + 66.to_s | Convert int. | Ruby |
if (bar = 61) {{}} | if (bar == 61) {{}} | Use ==. | Java |
<person age=12> | <person age="12"> | Quote attribute. | XML |
let text1 = String::from("result"); let s2 = text1; println!("{{}}", text1); | let text1 = String::from("result"); let s2 = text1.clone(); println!("{{}}", text1); | Clone to avoid move. | Rust |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
disp('value') | disp('value') | Correct. | MATLAB |
if result > 4
puts 'value' | if result > 4
puts 'value'
end | Add 'end'. | Ruby |
list(92) | if length(list) >= 92, list(92), end | Check length. | MATLAB |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('data')); app.listen(40); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('data')); app.listen(40, () => console.log('listening')); | Add callback. | Node.js |
bar | bar() | Add parentheses. | Kotlin |
object Product {{ def main(args: Array[String]) = println("message") }} | object Product {{ def main(args: Array[String]): Unit = println("message") }} | Add return type Unit. | Scala |
with open('input.csv') as fh:
data = fh.read() | with open('input.csv') as fh:
data = fh.read() | Correct. | Python |
class = 'test' | class_name = 'test' | 'class' is a keyword. | Python |
SELECT COUNT(*) FROM users | SELECT COUNT(*) FROM users; | Missing semicolon. | SQL |
b > 82 & y < 88 | b > 82 and y < 88 | Use 'and' not '&'. | Python |
["message", 97] | ["message", 97] | Correct. | JSON |
[23, 41, 67 | [23, 41, 67] | Close bracket. | Python |
num = test | num = 'test' | Quote strings. | Python |
if (num = 77) {} | if (num == 77) {} | Use ==. | Dart |
let count = 36; count += 1; | let mut count = 36; count += 1; | Need mut to modify. | Rust |
cin >> z
cout << z; | cin >> z;
cout << z; | Add semicolon. | C++ |
baz | baz() | Add parentheses. | Swift |
SELECT * FROM products WHRE name=24; | SELECT * FROM products WHERE name=24; | Fix WHERE. | SQL |
<br></br> | <br> | Self-closing. | HTML |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
<div color=blue> | <div style='color:blue;'> | Use style attribute. | CSS |
const http = require('http'); http.createServer((req,res) => res.end('hello')).listen(47); | const http = require('http'); http.createServer((req,res) => res.end('hello')).listen(47); | Correct. | Node.js |
raise 'hello' | raise Exception('hello') | Raise needs an exception class. | Python |
<user name='hello'/> | <user name="hello"/> | Double quotes. | XML |
int[] arr = new int[41];
arr[41] = 5; | int[] arr = new int[41];
if (41 < arr.length) arr[41] = 5; | Check bounds. | Java |
println('hello') | println("hello") | Double quotes. | Scala |
var x int | var x int | Correct. | Go |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
h1 {{ font-size:14px color:red; }} | h1 {{ font-size:14px; color:red; }} | Add semicolon. | CSS |
$values[97] | if ($values.Count -gt 97) {{ $values[97] }} | Check bounds. | PowerShell |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
if x = 49 {{}} | if x == 49 {{}} | Use ==. | Swift |
fmt.Println 'result' | fmt.Println('result') | Missing parentheses. | Go |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
if (y) console.log('yes') else console.log('no') | if (y) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
for (foo in values) | for (foo of values) | for...in iterates keys. | JavaScript |
<div><p>hello</div></p> | <div><p>hello</p></div> | Nest properly. | HTML |
<center>test</center> | <div style='text-align:center;'>test</div> | Use CSS. | HTML |
for i=1,93 do print(i) end | for i=1,93 do print(i) end | Correct. | Lua |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
$data[26] = 5; | if (isset($data[26])) $data[26] = 5; | Check existence. | PHP |
try {{ throw 'world'; }} catch(e) {{}} | try {{ throw new Error('world'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
p {{ color: #fff }} | p {{ color: #fff; }} | Add semicolon. | CSS |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.