wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
<br></br> | <br> | Self-closing. | HTML |
if ($val = 6) | if ($val == 6) | Use ==. | Perl |
if (z = 67) {{}} | if (z == 67) {{}} | Use ==. | Kotlin |
let z = 'data' | let z = "data" | Double quotes. | Swift |
<table><tr><td>test<td>world</tr></table> | <table><tr><td>test</td><td>world</td></tr></table> | Close td. | HTML |
$items[28] | if ($items.Count -gt 28) {{ $items[28] }} | Check bounds. | PowerShell |
function render(temp:string){{return temp;}} render(51); | function render(temp:string){{return temp;}} render('result'); | Pass correct type. | TypeScript |
handle | handle() | Add parentheses. | Kotlin |
local data = 30 | local data = 30 | Correct. | Lua |
let foo: Int = 'test' | let foo: String = 'test' | Fix type. | Swift |
arr[91] | if (length(arr) >= 91) arr[91] | Check length. | R |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
data[83] | if (data.indices.contains(83)) data[83] | Check index. | Kotlin |
cin >> x
cout << x; | cin >> x;
cout << x; | Add semicolon. | C++ |
class Child Entity: | class Child(Entity): | Inheritance uses parentheses. | Python |
value: info
value: hello, | value: info
value: hello | Remove comma. | YAML |
fmt.Println 'test' | fmt.Println('test') | Missing parentheses. | Go |
def test():
print('world') | def test():
print('world') | Indent function body. | Python |
p {{ color: red }} | p {{ color: red; }} | Add semicolon. | CSS |
<hr></hr> | <hr> | Self-closing. | HTML |
let x: number | null = null; x.toFixed(25); | let x: number | null = null; if(x!==null) x.toFixed(25); | Null check. | TypeScript |
void main() {{ print('message') }} | void main() {{ print('message'); }} | Add semicolon. | Dart |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
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 |
let x: i32 = "data"; | let x: &str = "data"; | Type mismatch. | Rust |
System.out.println('data') | System.out.println('data'); | Add semicolon. | Java |
with open('data.txt') as f:
data = f.read() | with open('data.txt') as f:
data = f.read() | Correct. | Python |
items(44) | if length(items) >= 44, items(44), end | Check length. | MATLAB |
[47, 92, 17 | [47, 92, 17] | Close bracket. | Python |
object User {{ def main(args: Array[String]) = println("test") }} | object User {{ def main(args: Array[String]): Unit = println("test") }} | Add return type Unit. | Scala |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
JOIN products ON users.id = products.name | JOIN products ON users.id = products.name | Correct. | SQL |
print 'hello' | print('hello') | print needs parentheses. | Python |
yield temp | yield temp | Correct yield. | Python |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
String val = 'value'; | String val = "value"; | Double quotes. | Java |
$a = 71; if ($a = 71) {{}} | $a = 71; if ($a == 71) {{}} | Use ==. | PHP |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
let str1 = String::from("message"); let str2 = str1; println!("{{}}", str1); | let str1 = String::from("message"); let str2 = str1.clone(); println!("{{}}", str1); | Clone to avoid move. | Rust |
class = 'test' | class_name = 'test' | 'class' is a keyword. | Python |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
echo value world | echo 'value world' | Quote to prevent splitting. | Shell |
x := 40 | x := 40 | Correct. | Go |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
fn compute() -> i32 {{ 13 }} | fn compute() -> i32 {{ 13 }} | Correct. | Rust |
<ul><li>hello<li>world</ul> | <ul><li>hello</li><li>world</li></ul> | Close li. | HTML |
disp('data') | disp('data') | Correct. | MATLAB |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
SELECT COUNT(*) FROM items | SELECT COUNT(*) FROM items; | Missing semicolon. | SQL |
def handle(count):
return count + 1 | def handle(count):
return count + 1 | Correct. | Python |
int* obj = nullptr; *obj=5; | int* obj = new int; *obj=5; | Allocate memory. | C++ |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
val a = 'data' | val a = "data" | Double quotes. | Kotlin |
<div><p>test</div></p> | <div><p>test</p></div> | Nest properly. | HTML |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
let v=vec![15,87,48]; let first=&v[0]; v.push(89); | let mut v=vec![15,87,48]; let first=v[0]; v.push(89); | Copy instead of reference. | Rust |
print 'info' | print 'info'; | Add semicolon. | Perl |
bar | bar() | Add parentheses. | Swift |
h1 {{ font-size:100px color:#fff; }} | h1 {{ font-size:100px; color:#fff; }} | Add semicolon. | CSS |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
if (a = 96) | if (a == 96) | Use ==. | R |
var x int | var x int | Correct. | Go |
if (x = 52) {{}} | if (x == 52) {{}} | Use ==. | Java |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
Write-Host 'message' | Write-Host 'message' | Correct. | PowerShell |
<div color=#333> | <div style='color:#333;'> | Use style attribute. | CSS |
b > 40 & y < 65 | b > 40 and y < 65 | Use 'and' not '&'. | Python |
while b > 33
b -= 1 | while b > 33:
b -= 1 | Colon missing after while. | Python |
<user name='world'/> | <user name="world"/> | Double quotes. | XML |
{{"age":"info",}} | {{"age":"info"}} | Remove trailing comma. | JSON |
if foo = 99 | if foo == 99 | Use ==. | Ruby |
{{'age':'data'}} | {{"age":"data"}} | Use double quotes. | JSON |
data[6] | if data.indices.contains(6) {{ data[6] }} | Check index. | Swift |
void baz();
int main(){{baz();}} | void baz(); // prototype
int main(){{baz();}} | Declare before use. | C++ |
if num = 93 {{}} | if num == 93 {{}} | Use ==. | Swift |
DELETE FROM products WHERE id=7 | DELETE FROM products WHERE id=7; | Add semicolon. | SQL |
{ "name": "data" } | { "name": "data" } | Correct. | JSON |
["value", 92] | ["value", 92] | Correct. | JSON |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
'output' + 100 | 'output' + str(100) | Can't add int to string. | Python |
<person age=3> | <person age="3"> | Quote attribute. | XML |
int num = 'test'; | String num = 'test'; | Type mismatch. | Dart |
if (b = 62) | if (b == 62) | Use ==. | C++ |
let x = 34; | let x = 34; | Correct. | JavaScript |
'world' + 4 | 'world' + 4.to_s | Convert int. | Ruby |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
function process() {{
return
{{key:'output'}}
}} | function process() {{
return {{key:'output'}};
}} | Return object on same line. | JavaScript |
WHERE name = '30' | WHERE name = 30 | Don't quote integer. | SQL |
jwt.sign({{id:65}}, 'key'); | jwt.sign({{id:65}}, 'key', {{expiresIn:'15m'}}); | Add expiration. | Node.js |
<p>value <b>world</p></b> | <p>value <b>world</b></p> | Nest properly. | HTML |
SELECT name email FROM users; | SELECT name, email FROM users; | Add comma. | SQL |
if ($val = 9) {{}} | if ($val -eq 9) {{}} | Use -eq. | PowerShell |
echo 'world' | echo 'world'; | Add semicolon. | PHP |
print('data') | print('data') | Correct. | R |
if result > 30
print('result') | if result > 30:
print('result') | Colon missing after if. | Python |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
INSERT INTO orders VALUES ('output',11) | INSERT INTO orders (id, status) VALUES ('output',11); | Specify columns. | SQL |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
my @arr = (88,85,92); | my @arr = (88,85,92); | Correct. | Perl |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.