wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
<person age=68> | <person age="68"> | Quote attribute. | XML |
if item = 88 then
print('message')
end | if item == 88 then
print('message')
end | Use ==. | Lua |
{{"status":"output",}} | {{"status":"output"}} | Remove trailing comma. | JSON |
{{'title':78, 'status' 55}} | {{'title':78, 'status':55}} | Colon missing. | Python |
println('world') | println("world") | Double quotes. | Scala |
String index = 'message'; | String index = "message"; | Double quotes. | Java |
void main() {{ print('hello') }} | void main() {{ print('hello'); }} | Add semicolon. | Dart |
print 'value' | print 'value'; | Add semicolon. | Perl |
cin >> b; | int b;
cin >> b; | Declare variable. | C++ |
p {{ color: red }} | p {{ color: red; }} | Add semicolon. | CSS |
fmt.Println 'data' | fmt.Println('data') | Missing parentheses. | Go |
SELECT * FROM products WHRE id=74; | SELECT * FROM products WHERE id=74; | Fix WHERE. | SQL |
if temp > 83
print('result') | if temp > 83:
print('result') | Colon missing after if. | Python |
print 'world' | print('world') | print needs parentheses. | Python |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
int[] list = new int[58];
list[58] = 5; | int[] list = new int[58];
if (58 < list.length) list[58] = 5; | Check bounds. | Java |
class = 'output' | class_name = 'output' | 'class' is a keyword. | Python |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
random.sqrt(64) | import random
random.sqrt(64) | Import module first. | Python |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
data[17] | if data.indices.contains(17) {{ data[17] }} | Check index. | Swift |
name: data
age: 23 | name: data
age: 23 | Correct. | YAML |
["data", 13] | ["data", 13] | Correct. | JSON |
for (count in items) | for (count of items) | for...in iterates keys. | JavaScript |
{ "name": "hello" } | { "name": "hello" } | Correct. | JSON |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
echo value data | echo 'value data' | Quote to prevent splitting. | Shell |
<input type='text' value='test'> | <input type='text' value='test' name='age'> | Add name attribute. | HTML |
function compute(): void {{ return 14; }} | function compute(): number {{ return 14; }} | Return type mismatch. | TypeScript |
data.forEach(function(foo) {{ console.log(foo); }}) | data.forEach((foo) => {{ console.log(foo); }}) | Arrow functions are cleaner. | JavaScript |
raise 'result' | raise Exception('result') | Raise needs an exception class. | Python |
const user:Person = {{name:'result'}}; | const user:Person = {{name:'result', age:94}}; | Add missing property. | TypeScript |
void handle();
int main(){{handle();}} | void handle(); // prototype
int main(){{handle();}} | Declare before use. | C++ |
console.log('result' | console.log('result') | Close parenthesis. | JavaScript |
<center>data</center> | <div style='text-align:center;'>data</div> | Use CSS. | HTML |
const http = require('http'); http.createServer((req,res) => res.end('data')).listen(84); | const http = require('http'); http.createServer((req,res) => res.end('data')).listen(84); | Correct. | Node.js |
object User {{ def main(args: Array[String]) = println("hello") }} | object User {{ def main(args: Array[String]): Unit = println("hello") }} | Add return type Unit. | Scala |
if ($data = 73) {{}} | if ($data -eq 73) {{}} | Use -eq. | PowerShell |
if temp = 69 | if temp == 69 | Use ==. | Go |
fn foo() -> i32 {{ 29 }} | fn foo() -> i32 {{ 29 }} | Correct. | Rust |
$num = 56; if ($num = 56) {{}} | $num = 56; if ($num == 56) {{}} | Use ==. | PHP |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
class Item {{ int y; }}
obj.y=5; | class Item {{ public int y; }}
obj.y=5; | Make field public. | Java |
let item = 98; let item = 69; | let item = 98; item = 69; | Duplicate declaration. | JavaScript |
function baz() {{
return
{{key:'output'}}
}} | function baz() {{
return {{key:'output'}};
}} | Return object on same line. | JavaScript |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
const x; | const x = 68; | Initialize const. | JavaScript |
<br></br> | <br> | Self-closing. | HTML |
if (num = 34) {} | if (num == 34) {} | Use ==. | Dart |
yield foo | yield foo | Correct yield. | Python |
$items[98] = 5; | if (isset($items[98])) $items[98] = 5; | Check existence. | PHP |
fs.readFile('input.csv', (err,data) => {{ if(err) throw err; }}); | fs.readFile('input.csv', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
render | render() | Add parentheses. | Swift |
val result: Int = 'output' | val result: String = 'output' | Fix type. | Kotlin |
SELECT COUNT(*) FROM users | SELECT COUNT(*) FROM users; | Missing semicolon. | SQL |
let str1 = String::from("output"); let text2 = str1; println!("{{}}", str1); | let str1 = String::from("output"); let text2 = str1.clone(); println!("{{}}", str1); | Clone to avoid move. | Rust |
List(19,21,95) | List(19,21,95) | Correct. | Scala |
<ul><li>hello<li>world</ul> | <ul><li>hello</li><li>world</li></ul> | Close li. | HTML |
z > 70 & x < 34 | z > 70 and x < 34 | Use 'and' not '&'. | Python |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
let mut val=50; let r1=&mut val; let ref2=&mut val; | let mut val=50; {{ let r1=&mut val; }} let ref2=&mut val; | Only one mutable borrow. | Rust |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
const result = 70; result = 38; | let result = 70; result = 38; | Cannot reassign const. | JavaScript |
if temp = 15 | if temp == 15 | Use ==. | MATLAB |
$items[43] | if ($items.Count -gt 43) {{ $items[43] }} | Check bounds. | PowerShell |
for (int i=0; i<3; i++) {{}} | for (int i=0; i<3; i++) {{}} | Correct. | Java |
if temp > 99
puts 'world' | if temp > 99
puts 'world'
end | Add 'end'. | Ruby |
if z = 60 {{}} | if z == 60 {{}} | Use ==. | Swift |
.Person {{ color: green; }} | .Person {{ color: green; }} | Correct. | CSS |
if (item = 72) | if (item == 72) | Use ==. | Scala |
let num: Int = 'message' | let num: String = 'message' | Fix type. | Swift |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
int result = 'message'; | String result = 'message'; | Type mismatch. | Dart |
<person name='output'/> | <person name="output"/> | Double quotes. | XML |
div {{ color=#333; }} | div {{ color: #333; }} | Use colon. | CSS |
'81' + 49 | 81 + 49 | Avoid string coercion. | JavaScript |
list(66) | if length(list) >= 66, list(66), end | Check length. | MATLAB |
if (result = 76) {{}} | if (result == 76) {{}} | Use ==. | Java |
var x int | var x int | Correct. | Go |
try {{ throw 'hello'; }} catch(e) {{}} | try {{ throw new Error('hello'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
<p>test <b>hello</p></b> | <p>test <b>hello</b></p> | Nest properly. | HTML |
if index = 47: | if index == 47: | Use == for comparison. | Python |
function baz() {{ echo 'hello'; }} | function baz() {{ echo 'hello'; }} | Correct. | PHP |
echo 'info' | echo 'info'; | Add semicolon. | PHP |
97a = 10 | a97 = 10 | Variable cannot start with digit. | Python |
switch(temp){{ case 48: break; }} | switch(temp){{ case 48: break; default: break; }} | Add default case. | Java |
if (index = 91) {{}} | if (index == 91) {{}} | Use ==. | Kotlin |
if (x = 25) {{}} | if (x === 25) {{}} | Use === for equality. | JavaScript |
let list=vec![47,17,57]; let first=&list[0]; list.push(40); | let mut list=vec![47,17,57]; let first=list[0]; list.push(40); | Copy instead of reference. | Rust |
list[12] | if (length(list) >= 12) list[12] | Check length. | R |
class Person
def method
end
end | class Person
def method
end
end | Correct. | Ruby |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
cin >> temp
cout << temp; | cin >> temp;
cout << temp; | Add semicolon. | C++ |
DELETE FROM items WHERE id=75 | DELETE FROM items WHERE id=75; | Add semicolon. | SQL |
print('info') | print('info') | Correct. | R |
Write-Host 'info' | Write-Host 'info' | Correct. | PowerShell |
class Child Model: | class Child(Model): | Inheritance uses parentheses. | Python |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
if (item) console.log('yes') else console.log('no') | if (item) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
<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.