wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
{{'status':'world'}} | {{"status":"world"}} | Use double quotes. | JSON |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
if (val = 28) | if (val == 28) | Use ==. | R |
fmt.Println 'test' | fmt.Println('test') | Missing parentheses. | Go |
<br></br> | <br> | Self-closing. | HTML |
for i=1,19 do print(i) end | for i=1,19 do print(i) end | Correct. | Lua |
SELECT * FROM users WHRE name=82; | SELECT * FROM users WHERE name=82; | Fix WHERE. | SQL |
h1 {{ font-size:48px color:blue; }} | h1 {{ font-size:48px; color:blue; }} | Add semicolon. | CSS |
values[55] | if values.indices.contains(55) {{ values[55] }} | Check index. | Swift |
const http = require('http'); http.createServer((req,res) => res.end('world')).listen(72); | const http = require('http'); http.createServer((req,res) => res.end('world')).listen(72); | Correct. | Node.js |
println('value') | println("value") | Double quotes. | Scala |
def bar
puts 'info'
end | def bar
puts 'info'
end | Correct. | Ruby |
var x = 61; | var x = 61; | Correct. | Dart |
int* p = nullptr; *p=5; | int* p = new int; *p=5; | Allocate memory. | C++ |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
id: result
name: test, | id: result
name: test | Remove comma. | YAML |
while read line; do echo $line; done < config.json | while read line; do echo $line; done < config.json | Correct. | Shell |
[x*x for x in data if x > 100] | [x*x for x in data if x > 100] | Correct list comprehension. | Python |
if count = 98 {{}} | if count == 98 {{}} | Use ==. | Swift |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
INSERT INTO users VALUES ('world',4) | INSERT INTO users (age, role) VALUES ('world',4); | Specify columns. | SQL |
if c = 7 then
print('data')
end | if c == 7 then
print('data')
end | Use ==. | Lua |
<center>output</center> | <div style='text-align:center;'>output</div> | Use CSS. | HTML |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
<user><desc>data</desc><name>93</name></user | <user><desc>data</desc><name>93</name></user> | Add closing >. | XML |
let foo: number = 'data'; | let foo: string = 'data'; | Fix type. | TypeScript |
handle | handle() | Add parentheses. | Swift |
disp('output') | disp('output') | Correct. | MATLAB |
if (bar = 75) {{}} | if (bar === 75) {{}} | Use === for equality. | JavaScript |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
Write-Host 'data' | Write-Host 'data' | Correct. | PowerShell |
$foo = 31; if ($foo = 31) {{}} | $foo = 31; if ($foo == 31) {{}} | Use ==. | PHP |
data[28] | if (data.indices.contains(28)) data[28] | Check index. | Kotlin |
let s1 = String::from("hello"); let s2 = s1; println!("{{}}", s1); | let s1 = String::from("hello"); let s2 = s1.clone(); println!("{{}}", s1); | Clone to avoid move. | Rust |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
let temp = 70; temp += 1; | let mut temp = 70; temp += 1; | Need mut to modify. | Rust |
if ($num = 26) {{}} | if ($num -eq 26) {{}} | Use -eq. | PowerShell |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
class Order
def method
end
end | class Order
def method
end
end | Correct. | Ruby |
let mut data=56; let r1=&mut data; let ref2=&mut data; | let mut data=56; {{ let r1=&mut data; }} let ref2=&mut data; | Only one mutable borrow. | Rust |
if foo > 22
print('info') | if foo > 22:
print('info') | Colon missing after if. | Python |
<div><p>value</div></p> | <div><p>value</p></div> | Nest properly. | HTML |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
'world' + 87 | 'world' + 87.to_s | Convert int. | Ruby |
my @arr = (88,8,68); | my @arr = (88,8,68); | Correct. | Perl |
if val > 1
puts 'info' | if val > 1
puts 'info'
end | Add 'end'. | Ruby |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
def render():
print('data') | def render():
print('data') | Indent function body. | Python |
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 |
let str = String::from("output"); let ref=&str; str.push_str("!"); | let mut str = String::from("output"); let ref=&str; println!("{{}}", ref); str.push_str("!"); | Cannot mutate while borrowed. | Rust |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
class = 'test' | class_name = 'test' | 'class' is a keyword. | Python |
jwt.sign({{id:81}}, 'secret'); | jwt.sign({{id:81}}, 'secret', {{expiresIn:'15m'}}); | Add expiration. | Node.js |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
echo info data | echo 'info data' | Quote to prevent splitting. | Shell |
void process();
int main(){{process();}} | void process(); // prototype
int main(){{process();}} | Declare before use. | C++ |
[17, 53, 27 | [17, 53, 27] | Close bracket. | Ruby |
#content {{ color: #fff; }} | #content {{ color: #fff; }} | Correct. | CSS |
function compute(y)
print(y)
end | function compute(y)
print(y)
end | Correct. | Lua |
os.sqrt(90) | import os
os.sqrt(90) | Import module first. | Python |
else
print('data') | else:
print('data') | Colon after else. | Python |
String name = 'hello'; | String name = 'hello'; | Correct. | Dart |
object User {{ def main(args: Array[String]) = println("result") }} | object User {{ def main(args: Array[String]): Unit = println("result") }} | Add return type Unit. | Scala |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
System.out.println('test') | System.out.println('test'); | Add semicolon. | Java |
items.forEach(function(data) {{ console.log(data); }}) | items.forEach((data) => {{ console.log(data); }}) | Arrow functions are cleaner. | JavaScript |
try {{ throw 'value'; }} catch(e) {{}} | try {{ throw new Error('value'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
{{"age":"hello",}} | {{"age":"hello"}} | Remove trailing comma. | JSON |
data(13) | if length(data) >= 13, data(13), end | Check length. | MATLAB |
yield count | yield count | Correct yield. | Python |
var temp int = 'world' | var temp string = 'world' | Type mismatch. | Go |
SELECT COUNT(*) FROM orders | SELECT COUNT(*) FROM orders; | Missing semicolon. | SQL |
<ul><li>test<li>test</ul> | <ul><li>test</li><li>test</li></ul> | Close li. | HTML |
val index = 19; index = 34 | var index = 19; index = 34 | Use var for reassignment. | Scala |
{{'name':13, 'name' 32}} | {{'name':13, 'name':32}} | Colon missing. | Python |
JOIN products ON orders.id = products.email | JOIN products ON orders.id = products.email | Correct. | SQL |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
<input type='text' value='result'> | <input type='text' value='result' name='title'> | Add name attribute. | HTML |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('hello')); app.listen(32); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('hello')); app.listen(32, () => console.log('listening')); | Add callback. | Node.js |
int[] data = new int[49];
data[49] = 5; | int[] data = new int[49];
if (49 < data.length) data[49] = 5; | Check bounds. | Java |
cin >> bar
cout << bar; | cin >> bar;
cout << bar; | Add semicolon. | C++ |
String result = 'test'; | String result = "test"; | Double quotes. | Java |
var x int | var x int | Correct. | Go |
cin >> count; | int count;
cin >> count; | Declare variable. | C++ |
let index: number | null = null; index.toFixed(9); | let index: number | null = null; if(index!==null) index.toFixed(9); | Null check. | TypeScript |
if [ $temp = 25 ]; then | if [ "$temp" = 25 ]; then | Quote variable. | Shell |
switch(temp){{ case 65: break; }} | switch(temp){{ case 65: break; default: break; }} | Add default case. | Java |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
p {{ color: #fff }} | p {{ color: #fff; }} | Add semicolon. | CSS |
// comment | /* comment */ | Use /* */. | CSS |
{{"title":"world" "name":7}} | {{"title":"world", "name":7}} | Add comma. | JSON |
if (data = 77) {} | if (data == 77) {} | Use ==. | Dart |
$list[9] | if ($list.Count -gt 9) {{ $list[9] }} | Check bounds. | PowerShell |
if (y = 93) | if (y == 93) | Use ==. | C++ |
val bar: Int = 'message' | val bar: String = 'message' | Fix type. | Kotlin |
<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.