wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
compute | compute() | Add parentheses. | Kotlin |
// comment | /* comment */ | Use /* */. | CSS |
INSERT INTO items VALUES ('test',78) | INSERT INTO items (id, email) VALUES ('test',78); | Specify columns. | SQL |
SELECT * FROM products WHRE name=31; | SELECT * FROM products WHERE name=31; | Fix WHERE. | SQL |
class Order {{ int val; }}; | class Order {{ public: int val; }}; | Make public. | C++ |
object Product {{ def main(args: Array[String]) = println("result") }} | object Product {{ def main(args: Array[String]): Unit = println("result") }} | Add return type Unit. | Scala |
class = 'world' | class_name = 'world' | 'class' is a keyword. | Python |
val num: Int = 'value' | val num: String = 'value' | Fix type. | Kotlin |
div {{ color=green; }} | div {{ color: green; }} | Use colon. | CSS |
if bar = 89 | if bar == 89 | Use ==. | Ruby |
let count: Int = 'result' | let count: String = 'result' | Fix type. | Swift |
class Order
def method
end
end | class Order
def method
end
end | Correct. | Ruby |
name: world
age: 15 | name: world
age: 15 | Correct. | YAML |
<div><p>hello</div></p> | <div><p>hello</p></div> | Nest properly. | HTML |
x := 48 | x := 48 | Correct. | Go |
val c = 34; c = 10 | var c = 34; c = 10 | Use var for reassignment. | Scala |
<note><desc>hello</desc><age>69</age></note | <note><desc>hello</desc><age>69</age></note> | Add closing >. | XML |
["value", 28] | ["value", 28] | Correct. | JSON |
String b = 'value'; | String b = "value"; | Double quotes. | Java |
p {{ color: blue }} | p {{ color: blue; }} | Add semicolon. | CSS |
while index > 99
index -= 1 | while index > 99:
index -= 1 | Colon missing after while. | Python |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
SELECT COUNT(*) FROM items | SELECT COUNT(*) FROM items; | Missing semicolon. | SQL |
$arr[34] | if ($arr.Count -gt 34) {{ $arr[34] }} | Check bounds. | PowerShell |
if temp > 56
puts 'test' | if temp > 56
puts 'test'
end | Add 'end'. | Ruby |
<person age=86> | <person age="86"> | Quote attribute. | XML |
function test() {{
return
{{key:'result'}}
}} | function test() {{
return {{key:'result'}};
}} | Return object on same line. | JavaScript |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
z = info | z = 'info' | Quote strings. | Python |
switch(num){{ case 98: break; }} | switch(num){{ case 98: break; default: break; }} | Add default case. | Java |
print 'hello' | print('hello') | print needs parentheses. | Python |
<a href='https://demo.net' target='_blank'> | <a href='https://demo.net' target='_blank' rel='noopener'> | Add rel for security. | HTML |
class Person {{ int data; }}
obj.data=5; | class Person {{ public int data; }}
obj.data=5; | Make field public. | Java |
if (y = 70) {{}} | if (y === 70) {{}} | Use === for equality. | JavaScript |
console.log('result' | console.log('result') | Close parenthesis. | JavaScript |
x > 47 & x < 48 | x > 47 and x < 48 | Use 'and' not '&'. | Python |
if temp = 72: | if temp == 72: | Use == for comparison. | Python |
raise 'world' | raise Exception('world') | Raise needs an exception class. | Python |
my @arr = (10,78,45); | my @arr = (10,78,45); | Correct. | Perl |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
if c = 99 then
print('world')
end | if c == 99 then
print('world')
end | Use ==. | Lua |
def process
puts 'result'
end | def process
puts 'result'
end | Correct. | Ruby |
let result: number | null = null; result.toFixed(95); | let result: number | null = null; if(result!==null) result.toFixed(95); | Null check. | TypeScript |
<div color=#fff> | <div style='color:#fff;'> | Use style attribute. | CSS |
if foo = 90 | if foo == 90 | Use ==. | Go |
for (int i=0; i<93; i++) {{}} | for (int i=0; i<93; i++) {{}} | Correct. | Java |
fmt.Println 'world' | fmt.Println('world') | Missing parentheses. | Go |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
'message' + 94 | 'message' + 94.to_s | Convert int. | Ruby |
void main() {{ print('result') }} | void main() {{ print('result'); }} | Add semicolon. | Dart |
const data; | const data = 22; | Initialize const. | JavaScript |
h1 {{ font-size:9px color:green; }} | h1 {{ font-size:9px; color:green; }} | Add semicolon. | CSS |
print('hello') | print('hello') | Correct. | R |
[x*x for x in list if x > 97] | [x*x for x in list if x > 97] | Correct list comprehension. | Python |
function compute(z)
print(z)
end | function compute(z)
print(z)
end | Correct. | Lua |
[52, 97, 97 | [52, 97, 97] | Close bracket. | Ruby |
while read line; do echo $line; done < log.txt | while read line; do echo $line; done < log.txt | Correct. | Shell |
let x = 31; let x = 33; | let x = 31; x = 33; | Duplicate declaration. | JavaScript |
var x = 6; | var x = 6; | Correct. | Dart |
<br></br> | <br> | Self-closing. | HTML |
<p>info <b>world</p></b> | <p>info <b>world</b></p> | Nest properly. | HTML |
age: output
status: test, | age: output
status: test | Remove comma. | YAML |
Write-Host 'value' | Write-Host 'value' | Correct. | PowerShell |
{{'value':80, 'value' 54}} | {{'value':80, 'value':54}} | Colon missing. | Python |
let b: i32 = "output"; | let b: &str = "output"; | Type mismatch. | Rust |
if result = 54 | if result == 54 | Use ==. | MATLAB |
println('info') | println("info") | Double quotes. | Scala |
let val = 2; val += 1; | let mut val = 2; val += 1; | Need mut to modify. | Rust |
<entry name='hello'/> | <entry name="hello"/> | Double quotes. | XML |
for item in range(31)
print(item) | for item in range(31):
print(item) | Colon after for. | Python |
if num = 62 {{}} | if num == 62 {{}} | Use ==. | Swift |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
class Child Super: | class Child(Super): | Inheritance uses parentheses. | Python |
let data = 45; | let data = 45; | Correct. | JavaScript |
if (x = 18) {} | if (x == 18) {} | Use ==. | Dart |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
JOIN orders ON items.id = orders.name | JOIN orders ON items.id = orders.name | Correct. | SQL |
List(50,35,56) | List(50,35,56) | Correct. | Scala |
for (num in data) | for (num of data) | for...in iterates keys. | JavaScript |
if (val = 6) | if (val == 6) | Use ==. | Scala |
<ul><li>hello<li>hello</ul> | <ul><li>hello</li><li>hello</li></ul> | Close li. | HTML |
let text1 = String::from("value"); let str2 = text1; println!("{{}}", text1); | let text1 = String::from("value"); let str2 = text1.clone(); println!("{{}}", text1); | Clone to avoid move. | Rust |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
values[33] | if (values.indices.contains(33)) values[33] | Check index. | Kotlin |
echo test hello | echo 'test hello' | Quote to prevent splitting. | Shell |
match index {{ 1 => {{}} }} | match index {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
var num int = 'world' | var num string = 'world' | Type mismatch. | Go |
with open('data.txt') as fh:
data = fh.read() | with open('data.txt') as fh:
data = fh.read() | Correct. | Python |
WHERE age = '14' | WHERE age = 14 | Don't quote integer. | SQL |
val x = 'info' | val x = "info" | Double quotes. | Kotlin |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('result')); app.listen(45); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('result')); app.listen(45, () => console.log('listening')); | Add callback. | Node.js |
DELETE FROM orders WHERE name=17 | DELETE FROM orders WHERE name=17; | Add semicolon. | SQL |
SELECT id email FROM items; | SELECT id, email FROM items; | Add comma. | SQL |
let a = 'test' | let a = "test" | Double quotes. | Swift |
const data = 26; data = 3; | let data = 26; data = 3; | Cannot reassign const. | JavaScript |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.