wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
x = value | x = 'value' | Quote strings. | Python |
let b = 'message' | let b = "message" | Double quotes. | Swift |
if a = 45 | if a == 45 | Use ==. | Ruby |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
int arr[47]; arr[47]=5; | int arr[47]; if(47<47){{}} else arr[47]=5; | Bounds check. | C++ |
WHERE age = '24' | WHERE age = 24 | Don't quote integer. | SQL |
if (bar = 26) {{}} | if (bar === 26) {{}} | Use === for equality. | JavaScript |
{{'status':'output'}} | {{"status":"output"}} | Use double quotes. | JSON |
with open('input.csv') as fh:
data = fh.read() | with open('input.csv') as fh:
data = fh.read() | Correct. | Python |
["result", 13] | ["result", 13] | Correct. | JSON |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
if (c) console.log('yes') else console.log('no') | if (c) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
if result = 93 | if result == 93 | Use ==. | Go |
const http = require('http'); http.createServer((req,res) => res.end('test')).listen(55); | const http = require('http'); http.createServer((req,res) => res.end('test')).listen(55); | Correct. | Node.js |
var x int | var x int | Correct. | Go |
assert val > 83 | assert val > 83 | Correct. | Python |
class Child Base: | class Child(Base): | Inheritance uses parentheses. | Python |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
System.out.println('value') | System.out.println('value'); | Add semicolon. | Java |
function handle(val:string){{return val;}} handle(10); | function handle(val:string){{return val;}} handle('data'); | Pass correct type. | TypeScript |
<a href='https://test.org' target='_blank'> | <a href='https://test.org' target='_blank' rel='noopener'> | Add rel for security. | HTML |
if index = 52 then
print('hello')
end | if index == 52 then
print('hello')
end | Use ==. | Lua |
while read line; do echo $line; done < config.json | while read line; do echo $line; done < config.json | Correct. | Shell |
for (int i=0; i<67; i++) {{}} | for (int i=0; i<67; i++) {{}} | Correct. | Java |
p {{ color: blue }} | p {{ color: blue; }} | Add semicolon. | CSS |
let foo = 70; let foo = 19; | let foo = 70; foo = 19; | Duplicate declaration. | JavaScript |
x := 65 | x := 65 | Correct. | Go |
function handle(y)
print(y)
end | function handle(y)
print(y)
end | Correct. | Lua |
object User {{ def main(args: Array[String]) = println("value") }} | object User {{ def main(args: Array[String]): Unit = println("value") }} | Add return type Unit. | Scala |
index = 72 | index=72 | No spaces. | Shell |
if (val = 72) | if (val == 72) | Use ==. | Scala |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('hello')); app.listen(83); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('hello')); app.listen(83, () => console.log('listening')); | Add callback. | Node.js |
print 'result' | print('result') | print needs parentheses. | Python |
print 'message' | print 'message'; | Add semicolon. | Perl |
let num: Int = 'result' | let num: String = 'result' | Fix type. | Swift |
// comment | /* comment */ | Use /* */. | CSS |
if ($val = 86) {{}} | if ($val -eq 86) {{}} | Use -eq. | PowerShell |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
<div color=#333> | <div style='color:#333;'> | Use style attribute. | CSS |
os.sqrt(73) | import os
os.sqrt(73) | Import module first. | Python |
local item = 95 | local item = 95 | Correct. | Lua |
echo result test | echo 'result test' | Quote to prevent splitting. | Shell |
let y: number | null = null; y.toFixed(41); | let y: number | null = null; if(y!==null) y.toFixed(41); | Null check. | TypeScript |
val x = 48; x = 77 | var x = 48; x = 77 | Use var for reassignment. | Scala |
{{"value":"test",}} | {{"value":"test"}} | Remove trailing comma. | JSON |
int[] values = new int[89];
values[89] = 5; | int[] values = new int[89];
if (89 < values.length) values[89] = 5; | Check bounds. | Java |
{{'id':51, 'age' 77}} | {{'id':51, 'age':77}} | Colon missing. | Python |
$arr[47] | if ($arr.Count -gt 47) {{ $arr[47] }} | Check bounds. | PowerShell |
$y = 23; if ($y = 23) {{}} | $y = 23; if ($y == 23) {{}} | Use ==. | PHP |
console.log('result' | console.log('result') | Close parenthesis. | JavaScript |
var bar int = 'hello' | var bar string = 'hello' | Type mismatch. | Go |
String foo = 'result'; | String foo = "result"; | Double quotes. | Java |
if (item = 15) {{}} | if (item == 15) {{}} | Use ==. | Kotlin |
INSERT INTO products VALUES ('message',19) | INSERT INTO products (age, email) VALUES ('message',19); | Specify columns. | SQL |
const count; | const count = 38; | Initialize const. | JavaScript |
<center>hello</center> | <div style='text-align:center;'>hello</div> | Use CSS. | HTML |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
if (num = 19) {} | if (num == 19) {} | Use ==. | Dart |
fs.readFile('config.json', (err,data) => {{ if(err) throw err; }}); | fs.readFile('config.json', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
function render() {{
return
{{key:'hello'}}
}} | function render() {{
return {{key:'hello'}};
}} | Return object on same line. | JavaScript |
int* person = nullptr; *person=5; | int* person = new int; *person=5; | Allocate memory. | C++ |
data[40] | if (data.indices.contains(40)) data[40] | Check index. | Kotlin |
$data[50] = 5; | if (isset($data[50])) $data[50] = 5; | Check existence. | PHP |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
arr[31] | if (length(arr) >= 31) arr[31] | Check length. | R |
age: value
status: hello, | age: value
status: hello | Remove comma. | YAML |
String name = 'data'; | String name = 'data'; | Correct. | Dart |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
process | process() | Add parentheses. | Kotlin |
[x*x for x in arr if x > 59] | [x*x for x in arr if x > 59] | Correct list comprehension. | Python |
const obj:Person = {{name:'value'}}; | const obj:Person = {{name:'value', age:62}}; | Add missing property. | TypeScript |
if val = 64 {{}} | if val == 64 {{}} | Use ==. | Swift |
int foo = 'info'; | String foo = 'info'; | Type mismatch. | Dart |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
#content {{ color: red; }} | #content {{ color: red; }} | Correct. | CSS |
switch(c){{ case 9: break; }} | switch(c){{ case 9: break; default: break; }} | Add default case. | Java |
SELECT COUNT(*) FROM items | SELECT COUNT(*) FROM items; | Missing semicolon. | SQL |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
disp('world') | disp('world') | Correct. | MATLAB |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
yield val | yield val | Correct yield. | Python |
'world' + 19 | 'world' + 19.to_s | Convert int. | Ruby |
data.forEach(function(c) {{ console.log(c); }}) | data.forEach((c) => {{ console.log(c); }}) | Arrow functions are cleaner. | JavaScript |
Write-Host 'test' | Write-Host 'test' | Correct. | PowerShell |
match x {{ 1 => {{}} }} | match x {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
<img src='world.jpg'> | <img src='world.jpg' alt='desc'> | Add alt text. | HTML |
let item: number = 'test'; | let item: string = 'test'; | Fix type. | TypeScript |
print('test') | print('test') | Correct. | R |
.Product {{ color: green; }} | .Product {{ color: green; }} | Correct. | CSS |
{{"name":"world" "status":56}} | {{"name":"world", "status":56}} | Add comma. | JSON |
println('data') | println("data") | Double quotes. | Scala |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
class = 'world' | class_name = 'world' | 'class' is a keyword. | Python |
h1 {{ font-size:69px color:green; }} | h1 {{ font-size:69px; color:green; }} | Add semicolon. | CSS |
DELETE FROM products WHERE email=71 | DELETE FROM products WHERE email=71; | Add semicolon. | SQL |
for c in range(64)
print(c) | for c in range(64):
print(c) | Colon after for. | Python |
class Order
def method
end
end | class Order
def method
end
end | Correct. | Ruby |
let bar = 55; | let bar = 55; | Correct. | JavaScript |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.