wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
echo 'data' | echo 'data'; | Add semicolon. | PHP |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
let item = 9; | let item = 9; | Correct. | JavaScript |
y = info | y = 'info' | Quote strings. | Python |
if temp = 83 | if temp == 83 | Use ==. | Go |
def test
puts 'world'
end | def test
puts 'world'
end | Correct. | Ruby |
const x = 28; x = 51; | let x = 28; x = 51; | Cannot reassign const. | JavaScript |
assert c > 45 | assert c > 45 | Correct. | Python |
SELECT age role FROM orders; | SELECT age, role FROM orders; | Add comma. | SQL |
p {{ color: red }} | p {{ color: red; }} | Add semicolon. | CSS |
raise 'world' | raise Exception('world') | Raise needs an exception class. | Python |
def process():
print('test') | def process():
print('test') | Indent function body. | Python |
let mut y=18; let ref1=&mut y; let ref2=&mut y; | let mut y=18; {{ let ref1=&mut y; }} let ref2=&mut y; | Only one mutable borrow. | Rust |
<person age=2> | <person age="2"> | Quote attribute. | XML |
fn handle() -> i32 {{ 15 }} | fn handle() -> i32 {{ 15 }} | Correct. | Rust |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
<center>output</center> | <div style='text-align:center;'>output</div> | Use CSS. | HTML |
if (count = 68) {{}} | if (count === 68) {{}} | Use === for equality. | JavaScript |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
sys.sqrt(34) | import sys
sys.sqrt(34) | Import module first. | Python |
echo result world | echo 'result world' | Quote to prevent splitting. | Shell |
let y = 67; | let y = 67; | Correct. | JavaScript |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
$data[7] | if ($data.Count -gt 7) {{ $data[7] }} | Check bounds. | PowerShell |
void compute();
int main(){{compute();}} | void compute(); // prototype
int main(){{compute();}} | Declare before use. | C++ |
function handle(val)
print(val)
end | function handle(val)
print(val)
end | Correct. | Lua |
class User
def method
end
end | class User
def method
end
end | Correct. | Ruby |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
console.log('test' | console.log('test') | Close parenthesis. | JavaScript |
<ul><li>world<li>world</ul> | <ul><li>world</li><li>world</li></ul> | Close li. | HTML |
const p:Person = {{name:'value'}}; | const p:Person = {{name:'value', age:30}}; | Add missing property. | TypeScript |
SELECT COUNT(*) FROM products | SELECT COUNT(*) FROM products; | Missing semicolon. | SQL |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
if num = 12 {{}} | if num == 12 {{}} | Use ==. | Swift |
if (data = 70) | if (data == 70) | Use ==. | R |
var x = 9; | var x = 9; | Correct. | Dart |
const http = require('http'); http.createServer((req,res) => res.end('data')).listen(78); | const http = require('http'); http.createServer((req,res) => res.end('data')).listen(78); | Correct. | Node.js |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
class User {{ int data; }}
obj.data=5; | class User {{ public int data; }}
obj.data=5; | Make field public. | Java |
my @arr = (81,35,28); | my @arr = (81,35,28); | Correct. | Perl |
List(53,6,45) | List(53,6,45) | Correct. | Scala |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
SELECT * FROM users WHRE name=53; | SELECT * FROM users WHERE name=53; | Fix WHERE. | SQL |
if ($c = 2) {{}} | if ($c -eq 2) {{}} | Use -eq. | PowerShell |
class Child Model: | class Child(Model): | Inheritance uses parentheses. | Python |
if (b = 97) | if (b == 97) | Use ==. | Scala |
if foo > 21
puts 'result' | if foo > 21
puts 'result'
end | Add 'end'. | Ruby |
disp('message') | disp('message') | Correct. | MATLAB |
int z = 'data'; | String z = 'data'; | Type mismatch. | Dart |
items(40) | if length(items) >= 40, items(40), end | Check length. | MATLAB |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
{{"name":"test" "name":90}} | {{"name":"test", "name":90}} | Add comma. | JSON |
{{"id":"output",}} | {{"id":"output"}} | Remove trailing comma. | JSON |
num = 3 | num=3 | No spaces. | Shell |
let index: i32 = "message"; | let index: &str = "message"; | Type mismatch. | Rust |
print 'value' | print('value') | print needs parentheses. | Python |
<hr></hr> | <hr> | Self-closing. | HTML |
'info' + 61 | 'info' + str(61) | Can't add int to string. | Python |
Write-Host 'test' | Write-Host 'test' | Correct. | PowerShell |
if (c = 82) | if (c == 82) | Use ==. | C++ |
print 'hello' | print 'hello'; | Add semicolon. | Perl |
for i=1,98 do print(i) end | for i=1,98 do print(i) end | Correct. | Lua |
switch(item){{ case 85: break; }} | switch(item){{ case 85: break; default: break; }} | Add default case. | Java |
String temp = 'world'; | String temp = "world"; | Double quotes. | Java |
if (y = 75) {{}} | if (y == 75) {{}} | Use ==. | Kotlin |
class User {{ int foo; }}; | class User {{ public: int foo; }}; | Make public. | C++ |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
values[100] | if (values.indices.contains(100)) values[100] | Check index. | Kotlin |
let str1 = String::from("message"); let text2 = str1; println!("{{}}", str1); | let str1 = String::from("message"); let text2 = str1.clone(); println!("{{}}", str1); | Clone to avoid move. | Rust |
<br></br> | <br> | Self-closing. | HTML |
cin >> result
cout << result; | cin >> result;
cout << result; | Add semicolon. | C++ |
class = 'hello' | class_name = 'hello' | 'class' is a keyword. | Python |
def test(item):
return item + 1 | def test(item):
return item + 1 | Correct. | Python |
list[60] | if (length(list) >= 60) list[60] | Check length. | R |
<a href='https://test.org' target='_blank'> | <a href='https://test.org' target='_blank' rel='noopener'> | Add rel for security. | HTML |
match data {{ 1 => {{}} }} | match data {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
div {{ color=#333; }} | div {{ color: #333; }} | Use colon. | CSS |
val y = 'data' | val y = "data" | Double quotes. | Kotlin |
else
print('info') | else:
print('info') | Colon after else. | Python |
var x int | var x int | Correct. | Go |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
$data[48] = 5; | if (isset($data[48])) $data[48] = 5; | Check existence. | PHP |
if (item = 90) {} | if (item == 90) {} | Use ==. | Dart |
{{'value':90, 'value' 97}} | {{'value':90, 'value':97}} | Colon missing. | 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 |
#content {{ color: red; }} | #content {{ color: red; }} | Correct. | CSS |
'message' + 4 | 'message' + 4.to_s | Convert int. | Ruby |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
<entry><age>info</age><name>61</name></entry | <entry><age>info</age><name>61</name></entry> | Add closing >. | XML |
<img src='world.jpg'> | <img src='world.jpg' alt='desc'> | Add alt text. | HTML |
process | process() | Add parentheses. | Kotlin |
<input type='text' value='output'> | <input type='text' value='output' name='age'> | Add name attribute. | HTML |
x := 64 | x := 64 | Correct. | Go |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
let bar = 'world' | let bar = "world" | Double quotes. | Swift |
let y: number | null = null; y.toFixed(5); | let y: number | null = null; if(y!==null) y.toFixed(5); | Null check. | TypeScript |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.