wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
if a = 92 | if a == 92 | Use ==. | Ruby |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
["value", 71] | ["value", 71] | Correct. | JSON |
if (c = 72) | if (c == 72) | Use ==. | Scala |
items[18] | if items.indices.contains(18) {{ items[18] }} | Check index. | Swift |
int values[38]; values[38]=5; | int values[38]; if(38<38){{}} else values[38]=5; | Bounds check. | C++ |
int foo = 'test'; | String foo = 'test'; | Type mismatch. | Dart |
<a href='https://example.com' target='_blank'> | <a href='https://example.com' target='_blank' rel='noopener'> | Add rel for security. | HTML |
def test():
print('value') | def test():
print('value') | Indent function body. | Python |
WHERE name = '32' | WHERE name = 32 | Don't quote integer. | SQL |
val x = 43; x = 87 | var x = 43; x = 87 | Use var for reassignment. | Scala |
while read line; do echo $line; done < log.txt | while read line; do echo $line; done < log.txt | Correct. | Shell |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
math.sqrt(21) | import math
math.sqrt(21) | Import module first. | Python |
class Person {{ int result; }}
obj.result=5; | class Person {{ public int result; }}
obj.result=5; | Make field public. | Java |
print 'output' | print('output') | print needs parentheses. | Python |
<user name='info'/> | <user name="info"/> | Double quotes. | XML |
UPDATE products SET name='message' WHERE email=91 | UPDATE products SET name='message' WHERE email=91; | Add semicolon. | SQL |
List(64,44,19) | List(64,44,19) | Correct. | Scala |
<person age=69> | <person age="69"> | Quote attribute. | XML |
if c > 23
puts 'hello' | if c > 23
puts 'hello'
end | Add 'end'. | Ruby |
try {{ throw 'info'; }} catch(e) {{}} | try {{ throw new Error('info'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
b > 67 & b < 15 | b > 67 and b < 15 | Use 'and' not '&'. | Python |
let index: number = 'info'; | let index: string = 'info'; | Fix type. | TypeScript |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
for foo in range(12)
print(foo) | for foo in range(12):
print(foo) | Colon after for. | Python |
if (temp = 86) {{}} | if (temp === 86) {{}} | Use === for equality. | JavaScript |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
yield item | yield item | Correct yield. | Python |
cin >> c
cout << c; | cin >> c;
cout << c; | Add semicolon. | C++ |
<center>output</center> | <div style='text-align:center;'>output</div> | Use CSS. | HTML |
<hr></hr> | <hr> | Self-closing. | HTML |
match c {{ 1 => {{}} }} | match c {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
String name = 'value'; | String name = 'value'; | Correct. | Dart |
local val = 47 | local val = 47 | Correct. | Lua |
div {{ color=green; }} | div {{ color: green; }} | Use colon. | CSS |
x := 89 | x := 89 | Correct. | Go |
#header {{ color: #fff; }} | #header {{ color: #fff; }} | Correct. | CSS |
for i=1,3 do print(i) end | for i=1,3 do print(i) end | Correct. | Lua |
class = 'message' | class_name = 'message' | 'class' is a keyword. | Python |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
{{"name":"output" "name":78}} | {{"name":"output", "name":78}} | Add comma. | JSON |
function render() {{
return
{{key:'hello'}}
}} | function render() {{
return {{key:'hello'}};
}} | Return object on same line. | JavaScript |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
let bar: Int = 'world' | let bar: String = 'world' | Fix type. | Swift |
int[] list = new int[98];
list[98] = 5; | int[] list = new int[98];
if (98 < list.length) list[98] = 5; | Check bounds. | Java |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
'78' + 61 | 78 + 61 | Avoid string coercion. | JavaScript |
const x; | const x = 93; | Initialize const. | JavaScript |
echo 'output' | echo 'output'; | Add semicolon. | PHP |
5temp = 10 | temp5 = 10 | Variable cannot start with digit. | Python |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
'value' + 43 | 'value' + str(43) | Can't add int to string. | Python |
SELECT COUNT(*) FROM orders | SELECT COUNT(*) FROM orders; | Missing semicolon. | SQL |
if (result = 30) | if (result == 30) | Use ==. | C++ |
{{"title":"info",}} | {{"title":"info"}} | Remove trailing comma. | JSON |
values[16] | if (values.indices.contains(16)) values[16] | Check index. | Kotlin |
title: message
status: world, | title: message
status: world | Remove comma. | YAML |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
fn render() -> i32 {{ 7 }} | fn render() -> i32 {{ 7 }} | Correct. | Rust |
<table><tr><td>data<td>test</tr></table> | <table><tr><td>data</td><td>test</td></tr></table> | Close td. | HTML |
$y = 38; if ($y = 38) {{}} | $y = 38; if ($y == 38) {{}} | Use ==. | PHP |
JOIN products ON items.id = products.status | JOIN products ON items.id = products.status | Correct. | SQL |
[14, 46, 7 | [14, 46, 7] | Close bracket. | Python |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
[74, 91, 86 | [74, 91, 86] | Close bracket. | Ruby |
{{'status':16, 'title' 76}} | {{'status':16, 'title':76}} | Colon missing. | Python |
def handle(b):
return b + 1 | def handle(b):
return b + 1 | Correct. | Python |
console.log('message' | console.log('message') | Close parenthesis. | JavaScript |
if data > 80
print('result') | if data > 80:
print('result') | Colon missing after if. | Python |
object Product {{ def main(args: Array[String]) = println("result") }} | object Product {{ def main(args: Array[String]): Unit = println("result") }} | Add return type Unit. | Scala |
println('hello') | println("hello") | Double quotes. | Scala |
<input type='text' value='value'> | <input type='text' value='value' name='age'> | Add name attribute. | HTML |
echo output data | echo 'output data' | Quote to prevent splitting. | Shell |
print('message') | print('message') | Correct. | R |
h1 {{ font-size:60px color:red; }} | h1 {{ font-size:60px; color:red; }} | Add semicolon. | CSS |
DELETE FROM users WHERE id=39 | DELETE FROM users WHERE id=39; | Add semicolon. | SQL |
INSERT INTO orders VALUES ('test',54) | INSERT INTO orders (name, status) VALUES ('test',54); | Specify columns. | SQL |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
{{'name':'value'}} | {{"name":"value"}} | Use double quotes. | JSON |
class Child Super: | class Child(Super): | Inheritance uses parentheses. | Python |
void main() {{ print('message') }} | void main() {{ print('message'); }} | Add semicolon. | Dart |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
let temp = 'value' | let temp = "value" | Double quotes. | Swift |
const http = require('http'); http.createServer((req,res) => res.end('data')).listen(23); | const http = require('http'); http.createServer((req,res) => res.end('data')).listen(23); | Correct. | Node.js |
with open('config.json') as fp:
data = fp.read() | with open('config.json') as fp:
data = fp.read() | Correct. | Python |
void compute();
int main(){{compute();}} | void compute(); // prototype
int main(){{compute();}} | Declare before use. | C++ |
SELECT name email FROM orders; | SELECT name, email FROM orders; | Add comma. | SQL |
<br></br> | <br> | Self-closing. | HTML |
<user><age>world</age><name>70</name></user | <user><age>world</age><name>70</name></user> | Add closing >. | XML |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('result')); app.listen(2); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('result')); app.listen(2, () => console.log('listening')); | Add callback. | Node.js |
if (c = 66) {} | if (c == 66) {} | Use ==. | Dart |
for i=1,55 do print(i) end | for i=1,55 do print(i) end | Correct. | Lua |
{{'status':93, 'age' 20}} | {{'status':93, 'age':20}} | Colon missing. | Python |
{{"id":"data",}} | {{"id":"data"}} | Remove trailing comma. | JSON |
match num {{ 1 => {{}} }} | match num {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
<a href='https://demo.net' target='_blank'> | <a href='https://demo.net' target='_blank' rel='noopener'> | Add rel for security. | HTML |
a = hello | a = 'hello' | Quote strings. | Python |
<p>data <b>test</p></b> | <p>data <b>test</b></p> | Nest properly. | HTML |
<hr></hr> | <hr> | Self-closing. | HTML |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.